com.googlecode.blaisemath.graph.view.VisualGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blaise-graph-theory-ui Show documentation
Show all versions of blaise-graph-theory-ui Show documentation
Swing UI components for blaise-graph-theory.
package com.googlecode.blaisemath.graph.view;
/*
* #%L
* BlaiseGraphTheory
* --
* Copyright (C) 2009 - 2019 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.Functions;
import com.google.common.graph.EndpointPair;
import com.google.common.graph.Graph;
import com.googlecode.blaisemath.coordinate.CoordinateManager;
import com.googlecode.blaisemath.graph.layout.GraphLayoutManager;
import com.googlecode.blaisemath.graphics.impl.DelegatingNodeLinkGraphic;
import com.googlecode.blaisemath.style.AttributeSet;
import com.googlecode.blaisemath.style.ObjectStyler;
import com.googlecode.blaisemath.graphics.Renderer;
import com.googlecode.blaisemath.style.Styles;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.awt.*;
import java.awt.geom.Point2D;
import java.beans.PropertyChangeListener;
import java.util.function.Supplier;
import static com.googlecode.blaisemath.graph.layout.GraphLayoutManager.P_GRAPH;
import com.googlecode.blaisemath.primitive.AnchoredText;
/**
* Combines a {@link GraphLayoutManager} and a {@link DelegatingNodeLinkGraphic}
* to manage a graph and its node locations. The graph is maintained by the manager,
* and the visual elements by the graphic.
*
* @param graphics canvas type
* @author Elisha Peterson
*/
public class VisualGraph {
/** Default graph node style */
public static final AttributeSet DEFAULT_NODE_STYLE = Styles.fillStroke(
new Color(0, 0, 128, 128), new Color(0, 0, 128, 192), .5f)
.and(Styles.MARKER_RADIUS, 3f);
/** Default graph edge style */
public static final AttributeSet DEFAULT_EDGE_STYLE = Styles.strokeWidth(
new Color(0, 128, 0, 128), 1f);
/** Responsible for instantiating the view graph */
private final @Nullable Supplier,G>> viewGraphSupplier;
/** Stores the visible graph */
private @Nullable DelegatingNodeLinkGraphic
© 2015 - 2024 Weber Informatics LLC | Privacy Policy