com.googlecode.blaisemath.graph.view.GraphComponent 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!
/*
* GraphComponent.java
* Created Jan 31, 2011
*/
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.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.googlecode.blaisemath.graph.Graph;
import com.googlecode.blaisemath.graph.GraphLayoutManager;
import com.googlecode.blaisemath.graph.modules.layout.SpringLayout;
import com.googlecode.blaisemath.graphics.core.DelegatingNodeLinkGraphic;
import com.googlecode.blaisemath.graphics.core.DelegatingPrimitiveGraphic;
import com.googlecode.blaisemath.graphics.core.Graphic;
import com.googlecode.blaisemath.graphics.swing.JGraphicComponent;
import com.googlecode.blaisemath.graphics.swing.JGraphics;
import com.googlecode.blaisemath.graphics.swing.PanAndZoomHandler;
import com.googlecode.blaisemath.style.ObjectStyler;
import com.googlecode.blaisemath.util.Edge;
import com.googlecode.blaisemath.util.coordinate.CoordinateManager;
import com.googlecode.blaisemath.util.swing.ContextMenuInitializer;
import java.awt.Graphics2D;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.util.Collection;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* Provides a view of a graph, using a {@link GraphLayoutManager} for positions/layout
* and a {@link VisualGraph} for appearance.
*
*
* The layout manager supports executing
* long-running layout algorithms in a background thread, and the visual graph
* shares a {@link CoordinateManager} that is used for updating locations from
* the layout manager. The coordinate manager is thread-safe.
*
*
* @author elisha
*/
public class GraphComponent extends JGraphicComponent {
public static final String MENU_KEY_GRAPH = "graph";
public static final String MENU_KEY_LINK = "link";
public static final String MENU_KEY_NODE = "node";
/** This mechanism is used to create the initial view graph for swing components, by setting up appropriate renderers. */
private static final Supplier,Graphics2D>> SWING_GRAPH_SUPPLIER
= new Supplier,Graphics2D>>() {
@Override
public DelegatingNodeLinkGraphic © 2015 - 2025 Weber Informatics LLC | Privacy Policy