Examples of VisualStyle


Examples of cytoscape.visual.VisualStyle

  protected abstract void createEdgeCalculators();
  protected abstract void createNodeCalculators();
  protected abstract void createVisualPropertyDependencies();
 
  public VisualStyle createVisualStyle(){
    VisualStyle vs = createVisualStyle(style, ncalcs, ecalcs);
    return vs;
   
  }
View Full Code Here

Examples of cytoscape.visual.VisualStyle

  /** Creates VisualStyle from the node and edge appearance calculators. */
  private VisualStyle createVisualStyle(CustomStyle style, Collection<Calculator> nodeAppearanceCalculators,
      Collection<Calculator> edgeAppearanceCalculators) {
    String name = style.toString();
    CySBML.LOGGER.config("createVisualStyle( " + name + " )");
    VisualStyle vs = new VisualStyle(name);
    VisualPropertyDependency deps = createVisualPropertyDependencies(vs);
   
    // add node appearance
    NodeAppearanceCalculator nac = new NodeAppearanceCalculator(deps);
    for (Calculator nc: nodeAppearanceCalculators){
      nac.setCalculator(nc);
    }
    vs.setNodeAppearanceCalculator(nac);
   
    // add edge appearance
    EdgeAppearanceCalculator eac = new EdgeAppearanceCalculator(deps);
    for (Calculator ec: edgeAppearanceCalculators){
      eac.setCalculator(ec);
    }
    vs.setEdgeAppearanceCalculator(eac);
   
    // add global appearance
    VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
    GlobalAppearanceCalculator gac = vmm.getVisualStyle().getGlobalAppearanceCalculator();
    gac.setDefaultBackgroundColor(new Color(new Float(1.0), new Float(1.0), new Float(1.0)));
    vs.setGlobalAppearanceCalculator(gac);
    return vs;
  }
View Full Code Here

Examples of cytoscape.visual.VisualStyle

    VisualMappingManager manager = Cytoscape.getVisualMappingManager();
    CalculatorCatalog catalog = manager.getCalculatorCatalog();
   
    // TODO: less brutal (properties are overwritten)
    String vsName = style.toString();
    VisualStyle vs = catalog.getVisualStyle(vsName);
    if (vs != null) {
      catalog.removeVisualStyle(vsName);
    }
    // only creates the style
    vs = createVisualStyle(style);
    catalog.addVisualStyle(vs);
    manager.setVisualStyle(vs);
   
    // TODO: better get the view for the network
    Cytoscape.getCurrentNetworkView().setVisualStyle(vs.getName());
    Cytoscape.getCurrentNetworkView().applyVizmapper(vs);
  }
View Full Code Here

Examples of cytoscape.visual.VisualStyle

  public static void setVisualStyleForCurrentView(){
    setVisualStyleForView(Cytoscape.getCurrentNetworkView());
  }
 
    public static void setVisualStyleForView(CyNetworkView view){
        VisualStyle vs = getCurrentVisualStyle();
        view.setVisualStyle(vs.getName());
    }
View Full Code Here

Examples of cytoscape.visual.VisualStyle

 
  /** Gets visual style from Calculator Catalog. */
  private static VisualStyle getVisualStyle(String vsName){
    VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
    CalculatorCatalog calcCatalog = vmm.getCalculatorCatalog();
    VisualStyle vs = calcCatalog.getVisualStyle(vsName);
    return vs;
  }
View Full Code Here

Examples of org.cytoscape.view.vizmap.VisualStyle

      double maxScore = resultsPanel.setNodeAttributesAndGetMaxScore();

      resultsPanel.selectCluster(null);

      VisualStyle appStyle = this.mcodeUtil.getAppStyle(maxScore);

      this.mcodeUtil.registerVisualStyle(appStyle);

      CyNetworkView netView = resultsPanel.getNetworkView();

      if ((netView != null) &&
        (this.visualMappingMgr.getVisualStyle(netView) == appStyle)) {
        appStyle.apply(netView);
        netView.updateView();
      }
    }
  }
View Full Code Here

Examples of org.cytoscape.view.vizmap.VisualStyle

        {
          CySubNetwork newNetwork = ResultPanel.this.mcodeUtil.createSubNetwork(clusterNetwork, clusterNetwork.getNodeList(),
            SavePolicy.SESSION_FILE);
          newNetwork.getRow(newNetwork).set("name", title);

          VisualStyle vs = ResultPanel.this.mcodeUtil.getNetworkViewStyle(ResultPanel.this.networkView);
          CyNetworkView newNetworkView = ResultPanel.this.mcodeUtil.createNetworkView(newNetwork, vs);

          newNetworkView.setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION, Double.valueOf(0.0D));
          newNetworkView.setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION, Double.valueOf(0.0D));
View Full Code Here

Examples of org.cytoscape.view.vizmap.VisualStyle

    }

    // keeps track of progress as a percent of the totalGoal
    double progress = 0;

    final VisualStyle vs = getClusterStyle();
    final CyNetworkView clusterView = createNetworkView(net, vs);

    clusterView.setVisualProperty(NETWORK_WIDTH, new Double(width));
    clusterView.setVisualProperty(NETWORK_HEIGHT, new Double(height));

    for (View<CyNode> nv : clusterView.getNodeViews()) {
      if (interrupted) {
        logger.debug("Interrupted: Node Setup");
        // before we short-circuit the method we reset the interruption so that the method can run without
        // problems the next time around
        if (layouter != null) layouter.resetDoLayout();
        resetLoading();

        return null;
      }

      // Node position
      final double x;
      final double y;

      // First we check if the Cluster already has a node view of this node (posing the more generic condition
      // first prevents the program from throwing a null pointer exception in the second condition)
      if (cluster.getView() != null && cluster.getView().getNodeView(nv.getModel()) != null) {
        //If it does, then we take the layout position that was already generated for it
        x = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_X_LOCATION);
        y = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_Y_LOCATION);
      } else {
        // Otherwise, randomize node positions before layout so that they don't all layout in a line
        // (so they don't fall into a local minimum for the SpringEmbedder)
        // If the SpringEmbedder implementation changes, this code may need to be removed
        // size is small for many default drawn graphs, thus +100
        x = (clusterView.getVisualProperty(NETWORK_WIDTH) + 100) * Math.random();
        y = (clusterView.getVisualProperty(NETWORK_HEIGHT) + 100) * Math.random();

        if (!layoutNecessary) {
          goalTotal += weightLayout;
          progress /= (goalTotal / (goalTotal - weightLayout));
          layoutNecessary = true;
        }
      }

      nv.setVisualProperty(NODE_X_LOCATION, x);
      nv.setVisualProperty(NODE_Y_LOCATION, y);

      // Node shape
      if (cluster.getSeedNode() == nv.getModel().getSUID()) {
        nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.RECTANGLE);
      } else {
        nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
      }

      // Update loader
      if (loader != null) {
        progress += 100.0 * (1.0 / (double) clusterView.getNodeViews().size()) *
              ((double) weightSetupNodes / (double) goalTotal);
        loader.setProgress((int) progress, "Setup: nodes");
      }
    }

    if (clusterView.getEdgeViews() != null) {
      for (int i = 0; i < clusterView.getEdgeViews().size(); i++) {
        if (interrupted) {
          logger.error("Interrupted: Edge Setup");
          if (layouter != null) layouter.resetDoLayout();
          resetLoading();

          return null;
        }

        if (loader != null) {
          progress += 100.0 * (1.0 / (double) clusterView.getEdgeViews().size()) *
                ((double) weightSetupEdges / (double) goalTotal);
          loader.setProgress((int) progress, "Setup: edges");
        }
      }
    }

    if (layoutNecessary) {
      if (layouter == null) {
        layouter = new SpringEmbeddedLayouter();
      }

      layouter.setGraphView(clusterView);

      // The doLayout method should return true if the process completes without interruption
      if (!layouter.doLayout(weightLayout, goalTotal, progress, loader)) {
        // Otherwise, if layout is not completed, set the interruption to false, and return null, not an image
        resetLoading();

        return null;
      }
    }

    final Image image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = (Graphics2D) image.getGraphics();

    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        try {
          final Dimension size = new Dimension(width, height);

          JPanel panel = new JPanel();
          panel.setPreferredSize(size);
          panel.setSize(size);
          panel.setMinimumSize(size);
          panel.setMaximumSize(size);
          panel.setBackground((Color) vs.getDefaultValue(NETWORK_BACKGROUND_PAINT));

          JWindow window = new JWindow();
          window.getContentPane().add(panel, BorderLayout.CENTER);

          RenderingEngine<CyNetwork> re = renderingEngineFactory.createRenderingEngine(panel, clusterView);

          vs.apply(clusterView);
          clusterView.fitContent();
          clusterView.updateView();
          window.pack();
          window.repaint();

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.