List of usage examples for java.awt Color cyan
Color cyan
To view the source code for java.awt Color cyan.
Click Source Link
From source file:gui.WikiCorpusClusteringView.java
/** * * @param br//w w w . java 2s . c om * @throws IOException */ private void setUpView(Graph graph) throws IOException { //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm // final AggregateLayout<Number, Number> layout = // new AggregateLayout<Number, Number>(new FRLayout<Number, Number>(graph)); //layout = new TreeLayout<String,Integer>(graph); Layout<Number, Number> layout = new KKLayout<Number, Number>(graph); layout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) { return THIN; } else { return THICK; } } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { //clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), // similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); //clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); //clusterAndRecolor(layout, numEdgesToRemove, similarColors, // groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:com.seagate.kinetic.monitor.view.KineticSpecifiedNodeView.java
private void createStatChart() { TimeSeriesCollection putOpsTsc = new TimeSeriesCollection(putOpsTs); TimeSeriesCollection putTrgTsc = new TimeSeriesCollection(putTrgTs); TimeSeriesCollection getOpsTsc = new TimeSeriesCollection(getOpsTs); TimeSeriesCollection getTrgTsc = new TimeSeriesCollection(getTrgTs); TimeSeriesCollection deleteOpsTsc = new TimeSeriesCollection(deleteOpsTs); TimeSeriesCollection deleteTrgTsc = new TimeSeriesCollection(deleteTrgTs); statChart = ChartFactory.createTimeSeriesChart("", "Time", "put kvop/s", putOpsTsc, true, true, false); XYPlot xyplot = (XYPlot) statChart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setDomainPannable(true);//from w w w .ja va 2 s . co m xyplot.setRangePannable(true); ValueAxis yAxis = xyplot.getDomainAxis(); yAxis.setAutoRange(true); yAxis.setFixedAutoRange(60000.0); NumberAxis numberaxis1 = new NumberAxis("get kvop/s"); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, getOpsTsc); xyplot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer standardxyitemrenderer1 = new StandardXYItemRenderer(); xyplot.setRenderer(1, standardxyitemrenderer1); NumberAxis numberaxis2 = new NumberAxis("delete kvop/s"); numberaxis2.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(2, numberaxis2); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(2, deleteOpsTsc); xyplot.mapDatasetToRangeAxis(2, 2); StandardXYItemRenderer standardxyitemrenderer2 = new StandardXYItemRenderer(); xyplot.setRenderer(2, standardxyitemrenderer2); NumberAxis numberaxis3 = new NumberAxis("put MB/s"); xyplot.setRangeAxis(3, numberaxis3); xyplot.setDataset(3, putTrgTsc); xyplot.mapDatasetToRangeAxis(3, 3); StandardXYItemRenderer standardxyitemrenderer3 = new StandardXYItemRenderer(); xyplot.setRenderer(3, standardxyitemrenderer3); NumberAxis numberaxis4 = new NumberAxis("get MB/s"); numberaxis4.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(4, numberaxis4); xyplot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(4, getTrgTsc); xyplot.mapDatasetToRangeAxis(4, 4); StandardXYItemRenderer standardxyitemrenderer4 = new StandardXYItemRenderer(); xyplot.setRenderer(4, standardxyitemrenderer4); NumberAxis numberaxis5 = new NumberAxis("delete MB/s"); xyplot.setRangeAxis(5, numberaxis5); xyplot.setDataset(5, deleteTrgTsc); xyplot.mapDatasetToRangeAxis(5, 5); StandardXYItemRenderer standardxyitemrenderer5 = new StandardXYItemRenderer(); xyplot.setRenderer(5, standardxyitemrenderer5); ChartUtilities.applyCurrentTheme(statChart); xyplot.getRenderer().setSeriesPaint(0, Color.black); standardxyitemrenderer1.setSeriesPaint(0, Color.red); numberaxis1.setLabelPaint(Color.red); numberaxis1.setTickLabelPaint(Color.red); standardxyitemrenderer2.setSeriesPaint(0, Color.green); numberaxis2.setLabelPaint(Color.green); numberaxis2.setTickLabelPaint(Color.green); standardxyitemrenderer3.setSeriesPaint(0, Color.orange); numberaxis3.setLabelPaint(Color.orange); numberaxis3.setTickLabelPaint(Color.orange); standardxyitemrenderer4.setSeriesPaint(0, Color.blue); numberaxis4.setLabelPaint(Color.blue); numberaxis4.setTickLabelPaint(Color.blue); standardxyitemrenderer5.setSeriesPaint(0, Color.cyan); numberaxis5.setLabelPaint(Color.cyan); numberaxis5.setTickLabelPaint(Color.cyan); final JPanel main = new JPanel(new BorderLayout()); final JPanel optionsPanel = new JPanel(); String[] options = { SYSTEM_TOTAL_IOPS_AND_THROUGHPUT_STATISTICS }; this.orientationComboBox = new JComboBox<String>(options); this.orientationComboBox.setSize(600, 50); this.orientationComboBox.addActionListener(this); optionsPanel.add(this.orientationComboBox); chartPanel = new ChartPanel(statChart); chartPanel.setMouseWheelEnabled(false); chartPanel.setPreferredSize(new Dimension(900, 450)); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); main.add(optionsPanel, BorderLayout.NORTH); main.add(this.chartPanel); setContentPane(main); }
From source file:visualizer.datamining.dataanalysis.NeighborhoodHit.java
private JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Hit", "Number Neighbors", "Precision", xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }
From source file:com.google.code.facebook.graph.sna.applet.MultiViewDemo.java
/** * create an instance of a simple graph in two views with controls to * demo the zoom features./*from w w w . j a va2 s. co m*/ * */ public MultiViewDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); // create one layout for the graph FRLayout<String, Number> layout = new FRLayout<String, Number>(graph); layout.setMaxIterations(1000); // create one model that all 3 views will share VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( layout, preferredSize); // create 3 views that share the same model vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>()); vv2.getRenderContext() .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12))); vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>()); vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>()); // transformer = vv1.getLayoutTransformer(); // vv2.setLayoutTransformer(transformer); // vv3.setLayoutTransformer(transformer); // // vv2.setViewTransformer(vv1.getViewTransformer()); // vv3.setViewTransformer(vv1.getViewTransformer()); vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer()); vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer()); vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1); vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2); vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3); vv1.setBackground(Color.white); vv2.setBackground(Color.white); vv3.setBackground(Color.white); // create one pick support for all 3 views to share GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1); vv1.setPickSupport(pickSupport); vv2.setPickSupport(pickSupport); vv3.setPickSupport(pickSupport); // create one picked state for all 3 views to share PickedState<Number> pes = new MultiPickedState<Number>(); PickedState<String> pvs = new MultiPickedState<String>(); vv1.setPickedVertexState(pvs); vv2.setPickedVertexState(pvs); vv3.setPickedVertexState(pvs); vv1.setPickedEdgeState(pes); vv2.setPickedEdgeState(pes); vv3.setPickedEdgeState(pes); // set an edge paint function that shows picked edges vv1.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv2.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv3.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv1.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow)); vv2.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan)); vv3.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow)); // add default listener for ToolTips vv1.setVertexToolTipTransformer(new ToStringLabeller()); vv2.setVertexToolTipTransformer(new ToStringLabeller()); vv3.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); JPanel panel = new JPanel(new GridLayout(1, 0)); final JPanel p1 = new JPanel(new BorderLayout()); final JPanel p2 = new JPanel(new BorderLayout()); final JPanel p3 = new JPanel(new BorderLayout()); p1.add(new GraphZoomScrollPane(vv1)); p2.add(new GraphZoomScrollPane(vv2)); p3.add(new GraphZoomScrollPane(vv3)); JButton h1 = new JButton("?"); h1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageOne); JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE); } }); JButton h2 = new JButton("?"); h2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageTwo); JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE); } }); JButton h3 = new JButton("?"); h3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageThree); textArea.setCaretPosition(0); JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE); } }); // create a GraphMouse for each view // each one has a different scaling plugin DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() { protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); add(scalingPlugin); setMode(Mode.TRANSFORMING); } }; DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() { protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); add(scalingPlugin); setMode(Mode.TRANSFORMING); } }; DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() { }; vv1.setGraphMouse(gm1); vv2.setGraphMouse(gm2); vv3.setGraphMouse(gm3); vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>"); vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>"); vv3.setToolTipText( "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>"); vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1")); vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2")); vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3")); textArea = new JTextArea(6, 30); scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); JPanel flow = new JPanel(); flow.add(h1); flow.add(gm1.getModeComboBox()); p1.add(flow, BorderLayout.SOUTH); flow = new JPanel(); flow.add(h2); flow.add(gm2.getModeComboBox()); p2.add(flow, BorderLayout.SOUTH); flow = new JPanel(); flow.add(h3); flow.add(gm3.getModeComboBox()); p3.add(flow, BorderLayout.SOUTH); panel.add(p1); panel.add(p2); panel.add(p3); content.add(panel); }
From source file:edu.uci.ics.jung.samples.MultiViewDemo.java
/** * create an instance of a simple graph in two views with controls to * demo the zoom features./*ww w .j av a 2s .c om*/ * */ @SuppressWarnings({ "unchecked", "rawtypes" }) public MultiViewDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); // create one layout for the graph FRLayout<String, Number> layout = new FRLayout<String, Number>(graph); layout.setMaxIterations(1000); // create one model that all 3 views will share VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( layout, preferredSize); // create 3 views that share the same model vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>()); vv2.getRenderContext() .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12))); vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>()); vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>()); // transformer = vv1.getLayoutTransformer(); // vv2.setLayoutTransformer(transformer); // vv3.setLayoutTransformer(transformer); // // vv2.setViewTransformer(vv1.getViewTransformer()); // vv3.setViewTransformer(vv1.getViewTransformer()); vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer()); vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer()); vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1); vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2); vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3); vv1.setBackground(Color.white); vv2.setBackground(Color.white); vv3.setBackground(Color.white); // create one pick support for all 3 views to share GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1); vv1.setPickSupport(pickSupport); vv2.setPickSupport(pickSupport); vv3.setPickSupport(pickSupport); // create one picked state for all 3 views to share PickedState<Number> pes = new MultiPickedState<Number>(); PickedState<String> pvs = new MultiPickedState<String>(); vv1.setPickedVertexState(pvs); vv2.setPickedVertexState(pvs); vv3.setPickedVertexState(pvs); vv1.setPickedEdgeState(pes); vv2.setPickedEdgeState(pes); vv3.setPickedEdgeState(pes); // set an edge paint function that shows picked edges vv1.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv2.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv3.getRenderContext() .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red)); vv1.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow)); vv2.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan)); vv3.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow)); // add default listener for ToolTips vv1.setVertexToolTipTransformer(new ToStringLabeller()); vv2.setVertexToolTipTransformer(new ToStringLabeller()); vv3.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); JPanel panel = new JPanel(new GridLayout(1, 0)); final JPanel p1 = new JPanel(new BorderLayout()); final JPanel p2 = new JPanel(new BorderLayout()); final JPanel p3 = new JPanel(new BorderLayout()); p1.add(new GraphZoomScrollPane(vv1)); p2.add(new GraphZoomScrollPane(vv2)); p3.add(new GraphZoomScrollPane(vv3)); JButton h1 = new JButton("?"); h1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageOne); JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE); } }); JButton h2 = new JButton("?"); h2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageTwo); JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE); } }); JButton h3 = new JButton("?"); h3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageThree); textArea.setCaretPosition(0); JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE); } }); // create a GraphMouse for each view // each one has a different scaling plugin DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() { protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); add(scalingPlugin); setMode(Mode.TRANSFORMING); } }; DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() { protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); add(scalingPlugin); setMode(Mode.TRANSFORMING); } }; DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() { }; vv1.setGraphMouse(gm1); vv2.setGraphMouse(gm2); vv3.setGraphMouse(gm3); vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>"); vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>"); vv3.setToolTipText( "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>"); vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1")); vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2")); vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3")); textArea = new JTextArea(6, 30); scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); JPanel flow = new JPanel(); flow.add(h1); flow.add(gm1.getModeComboBox()); p1.add(flow, BorderLayout.SOUTH); flow = new JPanel(); flow.add(h2); flow.add(gm2.getModeComboBox()); p2.add(flow, BorderLayout.SOUTH); flow = new JPanel(); flow.add(h3); flow.add(gm3.getModeComboBox()); p3.add(flow, BorderLayout.SOUTH); panel.add(p1); panel.add(p2); panel.add(p3); content.add(panel); }
From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java
private void initColorModels() { for (int j = 0; j <= 1; j++) { final int palSize = 256; final byte[] r = new byte[palSize]; final byte[] g = new byte[palSize]; final byte[] b = new byte[palSize]; final byte[] a = new byte[palSize]; r[0] = (byte) backgroundColor.getRed(); g[0] = (byte) backgroundColor.getGreen(); b[0] = (byte) backgroundColor.getBlue(); a[0] = (byte) backgroundColor.getAlpha(); final Palette pal = new Palette("Rainbow", new Color[] { Color.black, Color.blue, Color.cyan, Color.green, Color.yellow, Color.orange, Color.red }); for (int i = 1; i < 256; ++i) { float value = i / 255f; if (j == 0) value = (255 - i) / 255f; Color c = pal.lookupColor(value); r[i] = (byte) c.getRed(); g[i] = (byte) c.getGreen(); b[i] = (byte) c.getBlue(); a[i] = (byte) 255; }// ww w. ja v a2 s . c om if (j == 0) { toggledColorModel = new IndexColorModel(8, palSize, r, g, b, a); } else { untoggledColorModel = new IndexColorModel(8, palSize, r, g, b, a); } } }
From source file:semgen.extraction.RadialGraph.Clusterer.java
public void setUpView() throws IOException { setTitle(SemGenTab.formatTabName(extractor.semsimmodel.getName())); layout = new AggregateLayout<String, Number>(new SemGenFRLayout<String, Number>(mygraph)); vv = new VisualizationViewer<String, Number>(layout); // this class will provide both label drawing and vertex shapes VertexLabelAsShapeRenderer<String, Number> vlasr = new VertexLabelAsShapeRenderer<String, Number>( vv.getRenderContext());/*from w w w . jav a 2 s . co m*/ // customize the render context vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<String, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return input; } } })); vv.getRenderContext().setVertexShapeTransformer(vlasr); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.red)); vv.getRenderContext().setEdgeDrawPaintTransformer(new ConstantTransformer(Color.yellow)); vv.getRenderContext().setEdgeStrokeTransformer(new ConstantTransformer(new BasicStroke(2.5f))); // customize the renderer vv.getRenderer().setVertexLabelRenderer(vlasr); vv.setBackground(Color.white); // Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<String, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<String, Paint>() { public Paint transform(String v) { if (vv.getPickedVertexState().isPicked(v)) { if (selectioncheckbox != null) { extractor.clusterpanel.remove(selectioncheckbox); } Set<DataStructure> dsuris = new HashSet<DataStructure>(); for (String dsname : vv.getPickedVertexState().getPicked()) { dsuris.add(extractor.semsimmodel.getDataStructure(dsname)); } Component[] clusters = extractor.clusterpanel.checkboxpanel.getComponents(); extractor.clusterpanel.checkboxpanel.removeAll(); for (int x = -1; x < clusters.length; x++) { if (x == -1 && selectioncheckbox == null) { selectioncheckbox = new ExtractorJCheckBox("Selected node(s)", dsuris); selectioncheckbox.addItemListener(extractor); extractor.clusterpanel.checkboxpanel.add(selectioncheckbox); } else if (x > -1) { extractor.clusterpanel.checkboxpanel.add(clusters[x]); } } refreshModulePanel(); return Color.cyan; } else { if (vv.getPickedVertexState().getPicked().isEmpty()) { if (selectioncheckbox != null) { extractor.clusterpanel.checkboxpanel.remove(selectioncheckbox); selectioncheckbox = null; } } refreshModulePanel(); return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); // add restart button JButton scramble = new JButton("Shake"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout<String, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse<Object, Object> gm = new DefaultModalGraphMouse<Object, Object>(); vv.setGraphMouse(gm); groupVertices = new JToggleButton("Group Clusters"); // Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(350, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(mygraph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); if (mygraph.getEdgeCount() > 10) { edgeBetweennessSlider.setMajorTickSpacing(mygraph.getEdgeCount() / 10); } else { edgeBetweennessSlider.setMajorTickSpacing(1); } edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); clusterpanel = new JPanel(); clusterpanel.setLayout(new BoxLayout(clusterpanel, BoxLayout.Y_AXIS)); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); clusterpanel.add(gzsp); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); clusterpanel.add(south); clusterpanel.add(Box.createGlue()); semscroller = new SemGenScrollPane(sempanel); splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, semscroller, clusterpanel); splitpane.setDividerLocation(initsempanelwidth); splitpane.setDividerLocation(initsempanelwidth + 10); this.add(splitpane); this.setPreferredSize(new Dimension(950, 800)); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:es.urjc.ia.fia.genericSearch.statistics.JUNGStatistics.java
@Override public void showStatistics() { // Layout: tree and radial treeLayout = new TreeLayout<AuxVertex, ACTION>(this.tree, 35, 100); radialLayout = new RadialTreeLayout<AuxVertex, ACTION>(this.tree, 35, 130); radialLayout.setSize(new Dimension(200 * (this.tree.getHeight() + 1), 200 * (this.tree.getHeight() + 1))); // The BasicVisualizationServer<V,E> is parameterized by the edge types vv = new VisualizationViewer<AuxVertex, ACTION>(treeLayout); vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size vv.setBackground(Color.white); // Background color vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<AuxVertex>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); // Setup up a new vertex to paint transformer Transformer<AuxVertex, Paint> vertexPaint = new Transformer<AuxVertex, Paint>() { @Override// w w w .ja v a 2 s . com public Paint transform(AuxVertex arg0) { if (arg0.getState().isSolution() && arg0.isExplored()) { return Color.GREEN; } else if (arg0.isExplored()) { return Color.CYAN; } else if (arg0.isDuplicated()) { return Color.GRAY; } else { return Color.WHITE; } } }; // Tooltip for vertex Transformer<AuxVertex, String> toolTipsState = new Transformer<AuxVertex, String>() { @Override public String transform(AuxVertex arg0) { String sortInfo = ""; if (arg0.isExplored()) { if (arg0.getState().isSolution() && arg0.isExplored()) { sortInfo = "<u><i>Solution state " + arg0.getExplored() + "</i></u>"; } else { sortInfo = "<u><i>Explored state " + arg0.getExplored() + "</i></u>"; } } else if (arg0.isDuplicated()) { sortInfo = "<u><i>Duplicated state </i></u>"; } else { sortInfo = "<u><i>Unexplored state</i></u>"; } return "<html><p>" + sortInfo + "</p>" + "<p>State: " + arg0.getState().toString() + "</p>" + "<p>Cost: " + arg0.getState().getSolutionCost() + "</p></html>"; } }; vv.setVertexToolTipTransformer(toolTipsState); // Tooltip for edge Transformer<ACTION, String> toolTipsAction = new Transformer<ACTION, String>() { @Override public String transform(ACTION arg0) { return "Cost: " + arg0.cost(); } }; vv.setEdgeToolTipTransformer(toolTipsAction); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<ACTION>()); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); // Create a graph mouse and add it to the visualization component DefaultModalGraphMouse<State<ACTION>, ACTION> gm = new DefaultModalGraphMouse<State<ACTION>, ACTION>(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); vv.addKeyListener(gm.getModeKeyListener()); JFrame vFrame = new JFrame("Statistics Tree View"); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* vFrame.getContentPane().add(vv); vFrame.pack(); vFrame.setVisible(true); */ rings = new Rings(); Container content = vFrame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); JComboBox modeBox = gm.getModeComboBox(); modeBox.addItemListener(gm.getModeListener()); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, treeLayout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, radialLayout, treeLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); /* * Statistics */ JLabel stats = new JLabel(); long totalTime = endTime.getTime() - initTime.getTime(); stats.setText("<html>" + "<b>Total States:</b> " + this.totalStates + "<br>" + "<b>Explored States:</b> " + this.explorerStates + "<br>" + "<b>Duplicated States (detected):</b> " + this.duplicatedStates + "<br>" + "<b>Solution States:</b> " + this.solutionStates + "<br>" + "<b>Total time: </b>" + totalTime + " milliseconds" + "</html>"); JPanel legend = new JPanel(); legend.setLayout(new BoxLayout(legend, BoxLayout.Y_AXIS)); JLabel len = new JLabel("<html><b>Lengend</b></html>"); JLabel lexpl = new JLabel("Explored state"); lexpl.setBackground(Color.CYAN); lexpl.setOpaque(true); JLabel lune = new JLabel("Unexplored state"); lune.setBackground(Color.WHITE); lune.setOpaque(true); JLabel ldupl = new JLabel("Duplicated state"); ldupl.setBackground(Color.GRAY); ldupl.setOpaque(true); JLabel lsol = new JLabel("Solution state"); lsol.setBackground(Color.GREEN); lsol.setOpaque(true); legend.add(len); legend.add(lexpl); legend.add(lune); legend.add(ldupl); legend.add(lsol); JPanel controls = new JPanel(); controls.add(stats); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); //controls.add(modeBox); controls.add(legend); content.add(controls, BorderLayout.SOUTH); vFrame.pack(); vFrame.setVisible(true); }
From source file:visualizer.datamining.dataanalysis.NeighborhoodPreservation.java
private JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Preservation", "Number Neighbors", "Precision", xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }
From source file:visualizer.datamining.dataanalysis.CreateLineGraph.java
private JFreeChart createChart(XYDataset xydataset, String title, String xtitle, String ytitle) { JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }