org.apache.commons.collections15.Transformer Java Examples
The following examples show how to use
org.apache.commons.collections15.Transformer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransitionGraphCreator.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public Transformer<String, Paint> getVertexPaintTransformer(VisualizationViewer<String, String> viewer) { return new Transformer<String, Paint>() { @Override public Paint transform(String name) { if (viewer.getPickedVertexState().isPicked(name)) { return GraphViewer.NODE_SELECTED; } else if (sourceFilter.getSelectedIndex() > 0 && ((SourceId) sourceFilter.getSelectedItem()).getId().equals(name)) { return GraphViewer.NODE_ON_PATH; } else { return GraphViewer.NODE_BACKGROUND; } } }; }
Example #2
Source File: Prim.java From Algorithms with MIT License | 5 votes |
public static void display(Graphs graph, String color, String name){ Graph<Integer,Integer> g=convertGraph(graph); //VisualizationImageServer vs = new VisualizationImageServer(new CircleLayout(g), new Dimension(650, 650)); //Initialize visualization Layout<Integer, String> layout = new CircleLayout(g); layout.setSize(new Dimension(620,620)); VisualizationViewer<Integer,String> vs = new VisualizationViewer<Integer,String>(layout); vs.setPreferredSize(new Dimension(650,650)); //Creates GraphMouse and adds to visualization DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vs.setGraphMouse(gm); //Initialize JFrames JFrame frame = new JFrame(name); frame.getContentPane().setBackground(Color.RED); frame.getContentPane().add(vs); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); //Colors Vertices Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { if(color=="green"){ return Color.GREEN; } else{ return Color.RED; } } }; //Labels Edges float dash[] = {10.0f}; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<String, Stroke> edgeStrokeTransformer =new Transformer<String, Stroke>(){ public Stroke transform(String s) { return edgeStroke; } }; //Renders Vertex colors/labels vs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Renders Edge labels vs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); }
Example #3
Source File: VertexDemo.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void paintIconForVertex(RenderContext<V,E> rc, V v, Layout<V,E> layout) { Point2D p = layout.transform(v); p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p); float x = (float)p.getX(); float y = (float)p.getY(); GraphicsDecorator g = rc.getGraphicsContext(); boolean outlineImages = false; Transformer<V,Icon> vertexIconFunction = rc.getVertexIconTransformer(); if(vertexIconFunction instanceof DemoVertexIconTransformer) { outlineImages = ((DemoVertexIconTransformer<V>)vertexIconFunction).isOutlineImages(); } Icon icon = vertexIconFunction.transform(v); if(icon == null || outlineImages) { Shape s = AffineTransform.getTranslateInstance(x,y). createTransformedShape(rc.getVertexShapeTransformer().transform(v)); paintShapeForVertex(rc, v, s); } if(icon != null) { int xLoc = (int) (x - icon.getIconWidth()/2); int yLoc = (int) (y - icon.getIconHeight()/2); icon.paintIcon(rc.getScreenDevice(), g.getDelegate(), xLoc, yLoc); } }
Example #4
Source File: FrmPConns.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
private void setVisualizationViewer (VisualizationViewer vviewer) { PortConnections pconns = PortConnections.getInstance(); // give other color Transformer vertexPaint = new Transformer() { public Paint transform (Object obj) { if (obj instanceof ProcletBlock) { if (((ProcletBlock) obj).getBlockID().equals("exception")) { return Color.BLUE; } else { return Color.RED; } } else if (obj instanceof ProcletPort) { return Color.GREEN; } return Color.RED; } }; this.vertexPaint = vertexPaint; vv = vviewer; //vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv)); vv.setPreferredSize(new Dimension(350,350)); vv.getRenderContext().setVertexFillPaintTransformer(this.vertexPaint); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.setGraphMouse(gm); splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv)); // vv.validate(); // vv.repaint(); // splitPanelLeft.repaint(); // getContentPane().repaint(); // validate(); // repaint(); }
Example #5
Source File: Karger.java From Algorithms with MIT License | 4 votes |
public static void display(int[] vertices, int[][] edges, String color, String name){ Graph<Integer,Integer> g=convertGraph(vertices, edges); //VisualizationImageServer vs = new VisualizationImageServer(new CircleLayout(g), new Dimension(650, 650)); //Initialize visualization Layout<Integer, String> layout = new CircleLayout(g); layout.setSize(new Dimension(620,620)); VisualizationViewer<Integer,String> vs = new VisualizationViewer<Integer,String>(layout); vs.setPreferredSize(new Dimension(650,650)); //Creates GraphMouse and adds to visualization DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vs.setGraphMouse(gm); //Initialize JFrames JFrame frame = new JFrame(name); frame.getContentPane().setBackground(Color.RED); frame.getContentPane().add(vs); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); //Colors Vertices Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { if(color=="green"){ return Color.GREEN; } else{ return Color.RED; } } }; //Labels Edges float dash[] = {10.0f}; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<String, Stroke> edgeStrokeTransformer =new Transformer<String, Stroke>(){ public Stroke transform(String s) { return edgeStroke; } }; //Renders Vertex colors/labels vs.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vs.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Renders Edge labels vs.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); }
Example #6
Source File: ShapeBasedTreeLayout.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
public ShapeBasedTreeLayout(Forest<V, E> g, Transformer<V, Shape> shapeTransformer) { this.graph = g; this.roots = getRoots(g); this.shapeTransformer = shapeTransformer; calculateLocations(); }
Example #7
Source File: ShapeBasedTreeLayout.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public void setInitializer(Transformer<V, Point2D> initializer) {}
Example #8
Source File: GraphCreatorAdaptor.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** Returns null. */ @Override public Transformer<String, Paint> getVertexPaintTransformer(VisualizationViewer<String, String> viewer) { return null; }
Example #9
Source File: VertexDemo.java From yawl with GNU Lesser General Public License v3.0 | 4 votes |
public DemoVertexIconShapeTransformer(Transformer<V,Shape> delegate) { super(delegate); }
Example #10
Source File: DiagramGenerator.java From incubator-batchee with Apache License 2.0 | 4 votes |
private Rectangle getBound(final Node n, final Transformer<Node, Shape> vst) { if (vst == null) { return new Rectangle(0, 0); } return vst.transform(n).getBounds(); }
Example #11
Source File: GraphCreator.java From rapidminer-studio with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the transformer which maps vertices to the paint (color) used for drawing. May return * null. */ public Transformer<V, Paint> getVertexPaintTransformer(VisualizationViewer<V, E> viewer);