com.googlecode.blaisemath.graph.view.LongitudinalGraphComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blaise-graphtheory Show documentation
Show all versions of blaise-graphtheory Show documentation
Link graph definitions, algorithms, and visualization.
The newest version!
/*
* LongitudinalGraphComponent.java
* Created July 7, 2010
*/
package com.googlecode.blaisemath.graph.view;
/*
* #%L
* BlaiseGraphTheory
* --
* Copyright (C) 2009 - 2016 Elisha Peterson
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.googlecode.blaisemath.graph.Graph;
import com.googlecode.blaisemath.graph.GraphLayoutManager;
import com.googlecode.blaisemath.graph.longitudinal.LongitudinalGraph;
import com.googlecode.blaisemath.graph.modules.layout.SpringLayout;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.geom.Point2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.jdesktop.layout.GroupLayout;
/**
* This panel displays a longitudinal graph together with a slider bar that can
* be used to transition across various time slices of the graph. This panel also
* keeps track of the layout mechanism, which can then apply consistently across each
* slice of the graph.
*
* @author Elisha Peterson
*/
public final class LongitudinalGraphComponent extends JPanel {
/** Time graph manager */
private LongitudinalGraphManager manager;
/** Time slider */
private final LongitudinalGraphSlider slider;
/** Currently active graph component */
private final GraphComponent plot;
/** Time label (overlays on plot) */
private final JLabel timeLabel;
/** Replacement label for when view graph is exporting */
private final JLabel hideNote;
/** Handles manager changes */
private final PropertyChangeListener managerListener;
/** Constructs a longitudinal graph panel without an actual graph. */
public LongitudinalGraphComponent() {
this(null, null);
}
/**
* Construct instance with specified graph manager
* @param m graph manager
*/
public LongitudinalGraphComponent(LongitudinalGraphManager m) {
this(m, null);
}
/**
* Construct instance with specified graph manager
* @param m graph manager
* @param gm layout manager
*/
public LongitudinalGraphComponent(LongitudinalGraphManager m, GraphLayoutManager gm) {
super(new java.awt.BorderLayout());
plot = new GraphComponent();
slider = new LongitudinalGraphSlider();
timeLabel = new JLabel("Slice t=??");
hideNote = new JLabel("Exporting...");
initComponents();
managerListener = new PropertyChangeListener(){
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("time")) {
timeLabel.setText("Slice t="+evt.getNewValue());
} else if (evt.getPropertyName().equals("nodePositions")) {
Graph gr = manager.getSlice();
plot.getLayoutManager().setGraph(gr);
plot.getLayoutManager().requestLocations((Map © 2015 - 2025 Weber Informatics LLC | Privacy Policy