public void paintEdge(RenderContext<V,E> rc, Layout<V, E> layout, E e) { GraphicsDecorator g2d = rc.getGraphicsContext(); Graph<V,E> graph = layout.getGraph(); if (!rc.getEdgeIncludePredicate().apply(Context.<Graph<V,E>,E>getInstance(graph,e))) return; // don't draw edge if either incident vertex is not drawn Pair<V> endpoints = graph.getEndpoints(e); V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); if (!rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v1)) || !rc.getVertexIncludePredicate().apply(Context.<Graph<V,E>,V>getInstance(graph,v2))) return; Stroke new_stroke = rc.getEdgeStrokeTransformer().apply(e); Stroke old_stroke = g2d.getStroke(); if (new_stroke != null) g2d.setStroke(new_stroke); drawSimpleEdge(rc, layout, e); // restore paint and stroke if (new_stroke != null) g2d.setStroke(old_stroke); }
@Override public void stateChanged(ChangeEvent e) { if (e.getSource() == nodeSize) { // scale node shapes to size ONDEXMetaConceptShapes nodeShapes = (ONDEXMetaConceptShapes) viewer.getMetaGraphPanel().getVisualizationViewer().getRenderContext().getVertexShapeTransformer(); nodeShapes.setSize((Integer) nodeSize.getValue()); } else if (e.getSource() == edgeSize) { // update thickness of edge strokes ONDEXMetaRelationStrokes edgeStrokes = (ONDEXMetaRelationStrokes) viewer.getMetaGraphPanel().getVisualizationViewer().getRenderContext().getEdgeStrokeTransformer(); edgeStrokes.setThickness((Integer) edgeSize.getValue()); } else if (e.getSource() == fontSize && viewer.getMetaGraph().getVertexCount() > 0) { // set new font size Font f = viewer.getMetaGraphPanel().getVisualizationViewer().getRenderContext().getVertexFontTransformer().transform(viewer.getMetaGraph().getVertices().iterator().next()); LabelTransformer<ONDEXMetaRelation, Font> ef = new LabelTransformer<ONDEXMetaRelation, Font>(f, (Integer) fontSize.getValue()); viewer.getMetaGraphPanel().getVisualizationViewer().getRenderContext().setEdgeFontTransformer(ef); LabelTransformer<ONDEXMetaConcept, Font> cf = new LabelTransformer<ONDEXMetaConcept, Font>(f, (Integer) fontSize.getValue()); viewer.getMetaGraphPanel().getVisualizationViewer().getRenderContext().setVertexFontTransformer(cf); } viewer.getMetaGraphPanel().repaint(); }
/** * Sets viewer to be used in satellite view. * * @param viewer * OVTK2Viewer */ public void setViewer(OVTK2Viewer viewer) { this.viewer = viewer; // new satellite viewer satellite = new SatelliteVisualizationViewer<ONDEXConcept, ONDEXRelation>(viewer.getVisualizationViewer(), preferredSize); satellite.setPreferredSize(this.preferredSize); satellite.setSize(this.preferredSize); RenderContext<ONDEXConcept, ONDEXRelation> context = viewer.getVisualizationViewer().getRenderContext(); // configure satellite appearance satellite.getRenderContext().setVertexDrawPaintTransformer(context.getVertexDrawPaintTransformer()); satellite.getRenderContext().setVertexFillPaintTransformer(context.getVertexFillPaintTransformer()); satellite.getRenderContext().setVertexShapeTransformer(context.getVertexShapeTransformer()); satellite.getRenderContext().setEdgeDrawPaintTransformer(context.getEdgeDrawPaintTransformer()); satellite.getRenderContext().setEdgeArrowPredicate(context.getEdgeArrowPredicate()); satellite.getRenderContext().setEdgeStrokeTransformer(context.getEdgeStrokeTransformer()); // add to content pane this.getContentPane().removeAll(); this.getContentPane().add(satellite, BorderLayout.CENTER); JButton scaleToFit = new JButton(Config.language.getProperty("Satellite.ScaleToFit")); scaleToFit.addActionListener(this); this.getContentPane().add(scaleToFit, BorderLayout.SOUTH); this.revalidate(); // fit graph in scaleToFit(); }