Package org.jgraph.graph

Examples of org.jgraph.graph.GraphModel


  // Giuseppe De Cicco & Fabio Granara
  private void repositionSons(JmtCell padre, List<Object> sons, int numero, int cont) {
    inRepositionSons = true;
    Object[] listEdges = null;
    GraphModel graphmodel = graph.getModel();

    flag1 = true;

    int j = 0;
    Rectangle boundspadre = GraphConstants.getBounds(padre.getAttributes()).getBounds();
View Full Code Here


  {
    if(techtreePanel == null)
    {
      techtreePanel = new JPanel(new BorderLayout());
      techtreePanel.setOpaque(false);
      GraphModel gmodel = new DefaultGraphModel();
      GraphLayoutCache gcache = new GraphLayoutCache(gmodel,
        new DefaultCellViewFactory());
      JGraph graphPanel = new JGraph(gmodel, gcache);
     
      DefaultGraphCell[] cells = new DefaultGraphCell[144];
View Full Code Here

    public BasisPathController(GUIController control)
    {
        this.control = control;
        g = new ListenableDirectedGraph(DefaultEdge.class);

        GraphModel graphModel = new JGraphModelAdapter(g);
        graph = new JGraph(graphModel);

        //Add selection Listener to graph
        graph.addGraphSelectionListener(new GraphSelectionListenerImp(control));
     
View Full Code Here

public class HelloWorld {

  public static void main(String[] args) {

    // Construct Model and Graph
    GraphModel model = new DefaultGraphModel();
    JGraph graph = new JGraph(model);

    // Control-drag should clone selection
    graph.setCloneable(true);
View Full Code Here

            // graph already built, exiting silently
            return;
        }

        graph = new JGraph();
        GraphModel model = new DefaultGraphModel();
        graph.setModel(model);

        setProjectController(mediator);
        setDataDomain(domain);
View Full Code Here

   * applies a hierarchic layout on a given graph.
   *
   * @param graph
   */
   private static void applyHierarchicLayout(ReachabilityJGraph graph){
    GraphModel model = graph.getModel();
    LinkedList<ReachabilityPlaceModel> markings = new LinkedList<ReachabilityPlaceModel>();
    // get all marking and reset them to not recursively touched
    for(int i = 0; i < model.getRootCount(); i++){
      if(model.getRootAt(i) instanceof ReachabilityPlaceModel){
        ((ReachabilityPlaceModel) model.getRootAt(i)).setIsSetRecursiveBounds(false);
        markings.add((ReachabilityPlaceModel) model.getRootAt(i));
      }
    }
    // get initial marking. the begin oh each graph.
    ReachabilityPlaceModel initialPlace = AbstractReachabilityGraphModel.lookupInitialMarking(markings);
    if(initialPlace != null){
View Full Code Here

  private static Map<ReachabilityPlaceModel, AttributeMap> edit;
 
  public static ReachabilityJGraph layoutGraph(ReachabilityJGraph graph, Dimension dim){
    edit = new HashMap<ReachabilityPlaceModel, AttributeMap>();
    GraphModel model = graph.getModel();
    LinkedList<Point> coordinates = CircleCoordinates.getCircleCoordinates(dim.width,dim.height,AbstractReachabilityGraphModel.verticeCount(graph));
    // Build Graph
    LinkedList<ReachabilityPlaceModel> places = new LinkedList<ReachabilityPlaceModel>();
    for(int i = 0; i < model.getRootCount(); i++){
      if(model.getRootAt(i) instanceof ReachabilityPlaceModel){
        places.add((ReachabilityPlaceModel) model.getRootAt(i));
      }
    }
    ReachabilityPlaceModel initialPlace = AbstractReachabilityGraphModel.lookupInitialMarking(places);
    HashMap<String, String> graphAttributes = graph.getAttributeMap();
    if(initialPlace != null){
View Full Code Here

    public HashMap<String, String> getAttributeMap() {
        return graphAttributes;
    }

    public void deHighlight() {
        GraphModel model = getModel();
        for (int j = 0; j < model.getRootCount(); j++) {
            if (model.getRootAt(j) instanceof ReachabilityPlaceModel) {
                ((ReachabilityPlaceModel) model.getRootAt(j)).setHighlight(false);
            } else
                if (model.getRootAt(j) instanceof ReachabilityEdgeModel) {
                    ((ReachabilityEdgeModel) model.getRootAt(j)).setIngoing(false);
                    ((ReachabilityEdgeModel) model.getRootAt(j)).setOutgoing(false);
                }
        }
        getGraphLayoutCache().reload();
        clearSelection();
    }
View Full Code Here

     * @since 02.01.2009
     * @param mark
     */
    public void highlightMarking(IMarking mark) {
        deHighlight();
        GraphModel model = getModel();
        for (int j = 0; j < model.getRootCount(); j++) {
            if (model.getRootAt(j) instanceof ReachabilityPlaceModel) {

                ReachabilityPlaceModel rpm = (ReachabilityPlaceModel) model.getRootAt(j);
                if (mark.toString().equals(((IMarking) rpm.getUserObject()).toString())) {
                    rpm.setHighlight(true);
                    Rectangle2D re = GraphConstants.getBounds(rpm.getAttributes());
                    this.getVisibleRect();
                    JScrollBar scb = ((JScrollPane) getParent().getParent()).getVerticalScrollBar();
                    if (scb.isVisible()) {
                        // autoscroll down
                        while ((re.getMaxY() * this.scale) > (scb.getValue() + scb.getBounds().height)) {
                            scb.setValue(scb.getValue() + (scb.getBounds().height / 2));
                        }
                        // autoscroll up
                        while ((re.getMinY() * this.scale) < scb.getValue()) {
                            scb.setValue(scb.getValue() - (scb.getBounds().height / 2));
                        }
                    }
                    scb = ((JScrollPane) getParent().getParent()).getHorizontalScrollBar();
                    if (scb.isVisible()) {
                        // autoscroll right
                        while ((re.getMaxX() * this.scale) > (scb.getValue() + scb.getBounds().width)) {
                            scb.setValue(scb.getValue() + (scb.getBounds().width / 2));
                        }
                        // autoscroll left
                        while ((re.getMinX() * this.scale) < scb.getValue()) {
                            scb.setValue(scb.getValue() - (scb.getBounds().width / 2));
                        }
                    }
                }
            } else
                if (model.getRootAt(j) instanceof ReachabilityEdgeModel) {
                    // ((ReachabilityEdgeModel)model.getRootAt(j)).setIngoing(false);
                    // ((ReachabilityEdgeModel)model.getRootAt(j)).setOutgoing(false);
                }
        }
        getGraphLayoutCache().reload();
View Full Code Here

   * @return Object[] Array of parallel edges (include edge passed on
   *         argument)
   */
  protected Object[] getParallelEdges(GraphLayoutCache cache, EdgeView edge,
      CellView cellView1, CellView cellView2) {
    GraphModel model = cache.getModel();
    Object cell1 = cellView1.getCell();
    Object cell2 = cellView2.getCell();
    // Need to exit if a load has just been performed and the model
    // isn't in place properly yet
    Object[] roots = DefaultGraphModel.getRoots(model);
    if (roots.length == 0) {
      return null;
    }
    // Need to order cells so direction of the edges doesn't
    // affect the ordering of the output edges
    Object[] cells = new Object[] { cell1, cell2 };
    cells = DefaultGraphModel.order(model, cells);
    if (cells == null || cells.length < 2) {
      return null;
    }
    cell1 = cells[0];
    cell2 = cells[1];
    // System.out
    // .println("cell1 of parallel edges = "
    // + String.valueOf(((DefaultGraphCell) cell1)
    // .getUserObject()));
    while (model.getParent(cell1) != null && !cache.isVisible(cell1)) {
      cell1 = model.getParent(cell1);
      // if (cache.isVisible(cell1)) {
      // System.out
      // .println("cell1 promoted to = "
      // + String.valueOf(((DefaultGraphCell) cell1)
      // .getUserObject()));

      // }
    }
    // System.out
    // .println("cell2 of parallel edges = "
    // + String.valueOf(((DefaultGraphCell) cell2)
    // .getUserObject()));
    while (model.getParent(cell2) != null && !cache.isVisible(cell2)) {
      cell2 = model.getParent(cell2);
      // if (cache.isVisible(cell2)) {
      // System.out
      // .println("cell2 promoted to = "
      // + String.valueOf(((DefaultGraphCell) cell2)
      // .getUserObject()));
View Full Code Here

TOP

Related Classes of org.jgraph.graph.GraphModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.