List of usage examples for java.awt Color magenta
Color magenta
To view the source code for java.awt Color magenta.
Click Source Link
From source file:com.bwc.ora.views.LrpDisplayFrame.java
private void setChart(LrpSeries series) { lrpSeries = series.getLrpSeries();/*from ww w . j a va 2 s. co m*/ maximaSeries = series.getMaximaSeries(); hiddenMaximaSeries = series.getHiddenMaximaSeries(); graphData = new XYSeriesCollection(); //add series data to graph graphData.addSeries(lrpSeries); graphData.addSeries(maximaSeries); graphData.addSeries(hiddenMaximaSeries); series.getFwhmSeries().forEach(graphData::addSeries); //create the chart for displaying the data JFreeChart chart = ChartFactory.createXYLineChart("LRP", "Pixel Height", "Reflectivity", graphData, PlotOrientation.HORIZONTAL, true, true, false); chartPanel.setChart(chart); //create a custom renderer to control the display of each series //set draw properties for the LRP data HighlightXYRenderer renderer = new HighlightXYRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesPaint(0, Color.RED); //set draw properties for the maxima data renderer.setDrawOutlines(true); renderer.setUseOutlinePaint(true); renderer.setUseFillPaint(true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesShapesFilled(1, true); renderer.setSeriesFillPaint(1, Color.BLUE); renderer.setSeriesShape(1, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0)); //set draw properties for the hidden maxima data renderer.setSeriesLinesVisible(2, false); renderer.setSeriesShapesVisible(2, true); renderer.setSeriesShapesFilled(2, true); renderer.setSeriesFillPaint(2, Color.MAGENTA); renderer.setSeriesShape(2, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); //set draw properties for each of the full-width half-max lines for (int i = 3; i < series.getFwhmSeries().size() + 3; i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); renderer.setSeriesPaint(i, Color.BLACK); renderer.setSeriesVisibleInLegend(i, false, false); } chart.getXYPlot().setRenderer(renderer); //add listener for highlighting points when hovered over if (mouseMovementListener != null) { chartPanel.removeChartMouseListener(mouseMovementListener); } mouseMovementListener = getMovementChartMouseListener(renderer); chartPanel.addChartMouseListener(mouseMovementListener); //mark the Domain (which appears as the range in a horizontal graph) // axis as inverted so LRP matches with OCT ValueAxis domainAxis = chart.getXYPlot().getDomainAxis(); if (domainAxis instanceof NumberAxis) { NumberAxis axis = (NumberAxis) domainAxis; axis.setInverted(true); } //disable the need for the range of the chart to include zero ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis(); if (rangeAxis instanceof NumberAxis) { NumberAxis axis = (NumberAxis) rangeAxis; axis.setAutoRangeIncludesZero(false); } //if there were any previous annotations to the LRP add them to the chart lrps.getSelectedValue().getAnnotations().forEach(chart.getXYPlot()::addAnnotation); }
From source file:MyLink.java
public JPanel printableKSGenerate() { // create a simple graph for the demo graph = new SparseMultigraph<Integer, MyLink>(); Integer[] v = createVertices(getTermNum()); createEdges(v);/* w w w. j a v a 2 s.co m*/ vv = new VisualizationViewer<Integer, MyLink>(new KKLayout<Integer, MyLink>(graph)); vv.setPreferredSize(new Dimension(520, 520)); // 570, 640 | 565, 640 vv.getRenderContext().setVertexLabelTransformer(new UnicodeVertexStringer<Integer>(v)); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.magenta)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.magenta)); VertexIconShapeTransformer<Integer> vertexIconShapeFunction = new VertexIconShapeTransformer<Integer>( new EllipseVertexShapeTransformer<Integer>()); DefaultVertexIconTransformer<Integer> vertexIconFunction = new DefaultVertexIconTransformer<Integer>(); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); loadImages(v, vertexIconFunction.getIconMap()); vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap()); vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>( vv.getPickedVertexState(), new Color(0, 102, 255), Color.red)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<MyLink>(vv.getPickedEdgeState(), Color.orange, Color.cyan)); vv.setBackground(Color.white); final int maxSize = findMaxSizeNumber(); File file = new File("./output/DESC_TERM_COUNT.txt"); String s; try { BufferedReader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file))); s = fis.readLine(); userSelectedTermsCount = Integer.parseInt(s); termIndex = new int[userSelectedTermsCount]; int i = 0; while ((s = fis.readLine()) != null) { String[] tmp = s.split("="); termIndex[i] = Integer.parseInt(tmp[1].trim()); i++; } } catch (IOException e) { System.out.println(e.getMessage()); } Transformer<Integer, Shape> vertexSize = new Transformer<Integer, Shape>() { public Shape transform(Integer i) { double sizeInt = termIndex[i]; sizeInt = (double) sizeInt / (double) maxSize; sizeInt = (double) sizeInt * (double) 30 + 10; Ellipse2D circle = new Ellipse2D.Double(sizeInt / 2 * (-1), sizeInt / 2 * (-1), sizeInt, sizeInt); return circle; } }; vv.getRenderContext().setVertexShapeTransformer(vertexSize); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // create a frome to hold the graph APanel = new JPanel(); APanel.setLayout(new BoxLayout(APanel, BoxLayout.Y_AXIS)); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { 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()); } }); JCheckBox lo = new JCheckBox("Show Labels"); lo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { showLabels = e.getStateChange() == ItemEvent.SELECTED; vv.repaint(); } }); lo.setSelected(true); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); controls.add(lo); controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox()); APanel.add(vv); APanel.add(controls); return APanel; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleSettingsFactory.java
/** * *//*from w ww. j a v a2 s . c o m*/ public static final ChartThemeSettings createChartThemeSettings() { ChartThemeSettings settings = new ChartThemeSettings(); ChartSettings chartSettings = settings.getChartSettings(); chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); chartSettings.setBackgroundImage( new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png")); chartSettings.setBackgroundImageAlignment(Align.TOP_RIGHT); chartSettings.setBackgroundImageAlpha(1f); chartSettings.setBorderVisible(Boolean.TRUE); chartSettings.setBorderPaint(new ColorProvider(Color.GREEN)); chartSettings.setBorderStroke(new BasicStroke(1f)); chartSettings.setAntiAlias(Boolean.TRUE); chartSettings.setTextAntiAlias(Boolean.TRUE); chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); TitleSettings titleSettings = settings.getTitleSettings(); titleSettings.setShowTitle(Boolean.TRUE); titleSettings.setPosition(EdgeEnum.TOP); titleSettings.setForegroundPaint(new ColorProvider(Color.black)); titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); titleSettings.getFont().setBold(Boolean.TRUE); titleSettings.getFont().setFontSize(22f); titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER); titleSettings.setVerticalAlignment(VerticalAlignment.TOP); titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); TitleSettings subtitleSettings = settings.getSubtitleSettings(); subtitleSettings.setShowTitle(Boolean.TRUE); subtitleSettings.setPosition(EdgeEnum.TOP); subtitleSettings.setForegroundPaint(new ColorProvider(Color.red)); subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); subtitleSettings.getFont().setBold(Boolean.TRUE); subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT); subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER); subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); LegendSettings legendSettings = settings.getLegendSettings(); legendSettings.setShowLegend(Boolean.TRUE); legendSettings.setPosition(EdgeEnum.BOTTOM); legendSettings.setForegroundPaint(new ColorProvider(Color.black)); legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); legendSettings.getFont().setBold(Boolean.TRUE); legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER); legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM); //FIXMETHEME legendSettings.setBlockFrame(); legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); PlotSettings plotSettings = settings.getPlotSettings(); plotSettings.setOrientation(PlotOrientation.VERTICAL); // plotSettings.setForegroundAlpha(0.5f); plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); // plotSettings.setBackgroundAlpha(0.5f); plotSettings.setBackgroundImage( new FileImageProvider("net/sf/jasperreports/chartthemes/simple/jasperreports.png")); plotSettings.setBackgroundImageAlpha(0.5f); plotSettings.setBackgroundImageAlignment(Align.NORTH_WEST); plotSettings.setLabelRotation(0d); plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); plotSettings.setOutlineVisible(Boolean.TRUE); plotSettings.setOutlinePaint(new ColorProvider(Color.red)); plotSettings.setOutlineStroke(new BasicStroke(1f)); plotSettings.setSeriesColorSequence(COLORS); // plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS); plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER); plotSettings.setSeriesStrokeSequence(STROKES); plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES); plotSettings.setDomainGridlineVisible(Boolean.TRUE); plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY)); plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f)); plotSettings.setRangeGridlineVisible(Boolean.TRUE); plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK)); plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f)); plotSettings.getTickLabelFont().setFontName("Courier"); plotSettings.getTickLabelFont().setBold(Boolean.TRUE); plotSettings.getTickLabelFont().setFontSize(10f); plotSettings.getDisplayFont().setFontName("Arial"); plotSettings.getDisplayFont().setBold(Boolean.TRUE); plotSettings.getDisplayFont().setFontSize(12f); AxisSettings domainAxisSettings = settings.getDomainAxisSettings(); domainAxisSettings.setVisible(Boolean.TRUE); domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT); domainAxisSettings.setLinePaint(new ColorProvider(Color.green)); domainAxisSettings.setLineStroke(new BasicStroke(1f)); domainAxisSettings.setLineVisible(Boolean.TRUE); // domainAxisSettings.setLabel("Domain Axis"); domainAxisSettings.setLabelAngle(0.0d); domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta)); domainAxisSettings.getLabelFont().setBold(Boolean.TRUE); domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE); domainAxisSettings.getLabelFont().setFontName("Comic Sans MS"); domainAxisSettings.getLabelFont().setFontSize(12f); domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1)); domainAxisSettings.setLabelVisible(Boolean.TRUE); domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan)); domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE); domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE); domainAxisSettings.getTickLabelFont().setFontName("Arial"); domainAxisSettings.getTickLabelFont().setFontSize(10f); domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5)); domainAxisSettings.setTickLabelsVisible(Boolean.TRUE); domainAxisSettings.setTickMarksInsideLength(0.1f); domainAxisSettings.setTickMarksOutsideLength(0.2f); domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE)); domainAxisSettings.setTickMarksStroke(new BasicStroke(1f)); domainAxisSettings.setTickMarksVisible(Boolean.TRUE); domainAxisSettings.setTickCount(5); AxisSettings rangeAxisSettings = settings.getRangeAxisSettings(); rangeAxisSettings.setVisible(Boolean.TRUE); rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT); rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow)); rangeAxisSettings.setLineStroke(new BasicStroke(1f)); rangeAxisSettings.setLineVisible(Boolean.TRUE); // rangeAxisSettings.setLabel("Range Axis"); rangeAxisSettings.setLabelAngle(Math.PI / 2.0d); rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green)); rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE); rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE); rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS"); rangeAxisSettings.getLabelFont().setFontSize(12f); rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1)); rangeAxisSettings.setLabelVisible(Boolean.TRUE); rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink)); rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE); rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE); rangeAxisSettings.getTickLabelFont().setFontName("Arial"); rangeAxisSettings.getTickLabelFont().setFontSize(10f); rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5)); rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE); rangeAxisSettings.setTickMarksInsideLength(0.2f); rangeAxisSettings.setTickMarksOutsideLength(0.1f); rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black)); rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f)); rangeAxisSettings.setTickMarksVisible(Boolean.TRUE); rangeAxisSettings.setTickCount(6); return settings; }
From source file:gdsc.smlm.ij.plugins.pcpalm.PCPALMClusters.java
public void run(String arg) { if (!showDialog()) return;//from w w w . ja v a 2 s .co m PCPALMMolecules.logSpacer(); Utils.log(TITLE); PCPALMMolecules.logSpacer(); long start = System.currentTimeMillis(); HistogramData histogramData; if (fileInput) { histogramData = loadHistogram(histogramFile); } else { histogramData = doClustering(); } if (histogramData == null) return; float[][] hist = histogramData.histogram; // Create a histogram of the cluster sizes String title = TITLE + " Molecules/cluster"; String xTitle = "Molecules/cluster"; String yTitle = "Frequency"; // Create the data required for fitting and plotting float[] xValues = Utils.createHistogramAxis(hist[0]); float[] yValues = Utils.createHistogramValues(hist[1]); // Plot the histogram float yMax = Maths.max(yValues); Plot2 plot = new Plot2(title, xTitle, yTitle, xValues, yValues); if (xValues.length > 0) { double xPadding = 0.05 * (xValues[xValues.length - 1] - xValues[0]); plot.setLimits(xValues[0] - xPadding, xValues[xValues.length - 1] + xPadding, 0, yMax * 1.05); } Utils.display(title, plot); HistogramData noiseData = loadNoiseHistogram(histogramData); if (noiseData != null) { if (subtractNoise(histogramData, noiseData)) { // Update the histogram title += " (noise subtracted)"; xValues = Utils.createHistogramAxis(hist[0]); yValues = Utils.createHistogramValues(hist[1]); yMax = Maths.max(yValues); plot = new Plot2(title, xTitle, yTitle, xValues, yValues); if (xValues.length > 0) { double xPadding = 0.05 * (xValues[xValues.length - 1] - xValues[0]); plot.setLimits(xValues[0] - xPadding, xValues[xValues.length - 1] + xPadding, 0, yMax * 1.05); } Utils.display(title, plot); // Automatically save if (autoSave) { String newFilename = Utils.replaceExtension(histogramData.filename, ".noise.tsv"); if (saveHistogram(histogramData, newFilename)) { Utils.log("Saved noise-subtracted histogram to " + newFilename); } } } } // Fit the histogram double[] fitParameters = fitBinomial(histogramData); if (fitParameters != null) { // Add the binomial to the histogram int n = (int) fitParameters[0]; double p = fitParameters[1]; Utils.log("Optimal fit : N=%d, p=%s", n, Utils.rounded(p)); BinomialDistribution dist = new BinomialDistribution(n, p); // A zero-truncated binomial was fitted. // pi is the adjustment factor for the probability density. double pi = 1 / (1 - dist.probability(0)); if (!fileInput) { // Calculate the estimated number of clusters from the observed molecules: // Actual = (Observed / p-value) / N final double actual = (nMolecules / p) / n; Utils.log("Estimated number of clusters : (%d / %s) / %d = %s", nMolecules, Utils.rounded(p), n, Utils.rounded(actual)); } double[] x = new double[n + 2]; double[] y = new double[n + 2]; // Scale the values to match those on the histogram final double normalisingFactor = count * pi; for (int i = 0; i <= n; i++) { x[i] = i + 0.5; y[i] = dist.probability(i) * normalisingFactor; } x[n + 1] = n + 1.5; y[n + 1] = 0; // Redraw the plot since the limits may have changed plot = new Plot2(title, xTitle, yTitle, xValues, yValues); double xPadding = 0.05 * (xValues[xValues.length - 1] - xValues[0]); plot.setLimits(xValues[0] - xPadding, xValues[xValues.length - 1] + xPadding, 0, Maths.maxDefault(yMax, y) * 1.05); plot.setColor(Color.magenta); plot.addPoints(x, y, Plot2.LINE); plot.addPoints(x, y, Plot2.CIRCLE); plot.setColor(Color.black); Utils.display(title, plot); } double seconds = (System.currentTimeMillis() - start) / 1000.0; String msg = TITLE + " complete : " + seconds + "s"; IJ.showStatus(msg); Utils.log(msg); return; }
From source file:gov.nih.nci.caintegrator.common.Cai2Util.java
/** * Used by classes to retrieve a color based on a number from a ten color palette. * (1-10) are colors and anything else returns black. * @param colorNumber - number to use./* w w w . j a v a 2 s .c o m*/ * @return - Color object for that number. */ public static Color getBasicColor(int colorNumber) { switch (colorNumber) { case 1: return Color.GREEN; case 2: return Color.BLUE; case 3: return Color.RED; case 4: return Color.CYAN; case 5: return Color.DARK_GRAY; case 6: return Color.YELLOW; case 7: return Color.LIGHT_GRAY; case 8: return Color.MAGENTA; case 9: return Color.ORANGE; case 10: return Color.PINK; default: return Color.BLACK; } }
From source file:edu.cmu.sv.modelinference.eventtool.EventVisualizer.java
private static Map<EventClass, Color> assignClassColors(ClassificationResult results) { Color[] COLORS = { Color.GREEN, Color.RED, Color.BLACK, Color.BLUE, Color.GRAY, Color.CYAN, Color.DARK_GRAY, Color.MAGENTA }; int colorIdx = 0; Map<EventClass, Color> cluster2Color = new HashMap<>(); for (EventClass cl : results.getEventClasses()) { cluster2Color.put(cl, COLORS[colorIdx % COLORS.length]); colorIdx++;/*from ww w . j a va 2s.co m*/ } return cluster2Color; }
From source file:net.fenyo.gnetwatch.GUI.GenericSrcComponent.java
/** * Paints the chart.//w ww . ja va2s. co m * @param now current time. * @return void. */ // AWT thread // AWT thread << sync_value_per_vinterval << events public void paintChart(final long now) { backing_g.setClip(axis_margin_left + 1, axis_margin_top, dimension.width - axis_margin_left - axis_margin_right - 1, dimension.height - axis_margin_top - axis_margin_bottom); synchronized (events) { final int npoints = events.size(); final int point_x[] = new int[npoints]; final int point_y[] = new int[npoints]; final int point_y1[] = new int[npoints]; final int point_y2[] = new int[npoints]; final int point_y3[] = new int[npoints]; final int point_y4[] = new int[npoints]; final int point_y5[] = new int[npoints]; final int point_y6[] = new int[npoints]; final int point_y7[] = new int[npoints]; final int point_y8[] = new int[npoints]; final int point_y9[] = new int[npoints]; final int point_y10[] = new int[npoints]; final long time_to_display = now - now % _getDelayPerInterval(); final int pixels_offset = (pixels_per_interval * (int) (now % _getDelayPerInterval())) / (int) _getDelayPerInterval(); final int last_interval_pos = dimension.width - axis_margin_right - pixels_offset; for (int i = 0; i < events.size(); i++) { final EventGenericSrc event = (EventGenericSrc) events.get(i); final long xpos = ((long) last_interval_pos) + (((long) pixels_per_interval) * (event.getDate().getTime() - time_to_display)) / _getDelayPerInterval(); if (xpos < -1000) point_x[i] = -1000; else if (xpos > 1000 + dimension.width) point_x[i] = 1000 + dimension.width; else point_x[i] = (int) xpos; // cast to double to avoid overflow on int that lead to wrong results point_y[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getIntValue() / value_per_vinterval); point_y1[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue1() / value_per_vinterval); point_y2[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue2() / value_per_vinterval); point_y3[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue3() / value_per_vinterval); point_y4[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue4() / value_per_vinterval); point_y5[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue5() / value_per_vinterval); point_y6[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue6() / value_per_vinterval); point_y7[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue7() / value_per_vinterval); point_y8[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue8() / value_per_vinterval); point_y9[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue9() / value_per_vinterval); point_y10[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue10() / value_per_vinterval); } backing_g.setColor(Color.GREEN); backing_g.drawPolyline(point_x, point_y, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y[i] - 2, 4, 4); backing_g.setColor(Color.WHITE); backing_g.drawPolyline(point_x, point_y1, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y1[i] - 2, 4, 4); backing_g.setColor(Color.BLUE); backing_g.drawPolyline(point_x, point_y2, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y2[i] - 2, 4, 4); backing_g.setColor(Color.GRAY); backing_g.drawPolyline(point_x, point_y3, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y3[i] - 2, 4, 4); backing_g.setColor(Color.YELLOW); backing_g.drawPolyline(point_x, point_y4, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y4[i] - 2, 4, 4); backing_g.setColor(Color.ORANGE); backing_g.drawPolyline(point_x, point_y5, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y5[i] - 2, 4, 4); backing_g.setColor(Color.CYAN); backing_g.drawPolyline(point_x, point_y6, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y6[i] - 2, 4, 4); backing_g.setColor(Color.MAGENTA); backing_g.drawPolyline(point_x, point_y7, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y7[i] - 2, 4, 4); backing_g.setColor(Color.LIGHT_GRAY); backing_g.drawPolyline(point_x, point_y8, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y8[i] - 2, 4, 4); backing_g.setColor(Color.PINK); backing_g.drawPolyline(point_x, point_y9, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y9[i] - 2, 4, 4); backing_g.setColor(Color.RED); backing_g.drawPolyline(point_x, point_y10, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y10[i] - 2, 4, 4); int cnt = 1; int cnt2 = 1; if (events.size() > 0) for (final String str : ((EventGenericSrc) events.get(0)).getUnits().split(";")) { if (str.length() > 0) { switch (cnt) { case 1: backing_g.setColor(Color.WHITE); break; case 2: backing_g.setColor(Color.BLUE); break; case 3: backing_g.setColor(Color.GRAY); break; case 4: backing_g.setColor(Color.YELLOW); break; case 5: backing_g.setColor(Color.ORANGE); break; case 6: backing_g.setColor(Color.CYAN); break; case 7: backing_g.setColor(Color.MAGENTA); break; case 8: backing_g.setColor(Color.LIGHT_GRAY); break; case 9: backing_g.setColor(Color.PINK); break; case 10: backing_g.setColor(Color.RED); break; } backing_g.fillRect(dimension.width - axis_margin_right - 150, 50 - 5 + 13 * cnt2, 20, 3); backing_g.setColor(Color.WHITE); backing_g.drawString(str, dimension.width - axis_margin_right - 150 + 22, 50 + 13 * cnt2); cnt2++; } cnt++; } backing_g.setClip(null); } }
From source file:gdsc.smlm.ij.plugins.DiffusionRateTest.java
public void run(String arg) { if (!showDialog()) return;//from www . j a v a 2 s .co m int totalSteps = settings.seconds * settings.stepsPerSecond; final double conversionFactor = 1000000.0 / (settings.pixelPitch * settings.pixelPitch); // Diffusion rate is um^2/sec. Convert to pixels per simulation frame. final double diffusionRateInPixelsPerSecond = settings.diffusionRate * conversionFactor; final double diffusionRateInPixelsPerStep = diffusionRateInPixelsPerSecond / settings.stepsPerSecond; Utils.log(TITLE + " : D = %s um^2/sec", Utils.rounded(settings.diffusionRate, 4)); Utils.log("Mean-displacement per dimension = %s nm/sec", Utils.rounded(1e3 * ImageModel.getRandomMoveDistance(settings.diffusionRate), 4)); // Convert diffusion co-efficient into the standard deviation for the random walk final double diffusionSigma = ImageModel.getRandomMoveDistance(diffusionRateInPixelsPerStep); Utils.log("Simulation step-size = %s nm", Utils.rounded(settings.pixelPitch * diffusionSigma, 4)); // Move the molecules and get the diffusion rate IJ.showStatus("Simulating ..."); final long start = System.nanoTime(); RandomGenerator random = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this)); Statistics[] stats2D = new Statistics[totalSteps]; Statistics[] stats3D = new Statistics[totalSteps]; for (int j = 0; j < totalSteps; j++) { stats2D[j] = new Statistics(); stats3D[j] = new Statistics(); } SphericalDistribution dist = new SphericalDistribution(settings.confinementRadius / settings.pixelPitch); Statistics asymptote = new Statistics(); for (int i = 0; i < settings.particles; i++) { if (i % 16 == 0) IJ.showProgress(i, settings.particles); MoleculeModel m = new MoleculeModel(i, new double[3]); if (useConfinement) { // Note: When using confinement the average displacement should asymptote // at the average distance of a point from the centre of a ball. This is 3r/4. // See: http://answers.yahoo.com/question/index?qid=20090131162630AAMTUfM // The equivalent in 2D is 2r/3. However although we are plotting 2D distance // this is a projection of the 3D position onto the plane and so the particles // will not be evenly spread (there will be clustering at centre caused by the // poles) for (int j = 0; j < totalSteps; j++) { double[] xyz = m.getCoordinates(); double[] originalXyz = Arrays.copyOf(xyz, 3); for (int n = confinementAttempts; n-- > 0;) { if (settings.useGridWalk) m.walk(diffusionSigma, random); else m.move(diffusionSigma, random); if (!dist.isWithin(m.getCoordinates())) { // Reset position for (int k = 0; k < 3; k++) xyz[k] = originalXyz[k]; } else { // The move was allowed break; } } stats2D[j].add(squared(m.getCoordinates())); stats3D[j].add(distance2(m.getCoordinates())); } asymptote.add(distance(m.getCoordinates())); } else { if (settings.useGridWalk) { for (int j = 0; j < totalSteps; j++) { m.walk(diffusionSigma, random); stats2D[j].add(squared(m.getCoordinates())); stats3D[j].add(distance2(m.getCoordinates())); } } else { for (int j = 0; j < totalSteps; j++) { m.move(diffusionSigma, random); stats2D[j].add(squared(m.getCoordinates())); stats3D[j].add(distance2(m.getCoordinates())); } } } // Debug: record all the particles so they can be analysed // System.out.printf("%f %f %f\n", m.getX(), m.getY(), m.getZ()); } final double time = (System.nanoTime() - start) / 1000000.0; IJ.showStatus("Analysing results ..."); IJ.showProgress(1); if (showDiffusionExample) { showExample(totalSteps, diffusionSigma, random); } // Plot a graph of mean squared distance double[] xValues = new double[stats2D.length]; double[] yValues2D = new double[stats2D.length]; double[] yValues3D = new double[stats3D.length]; double[] upper = new double[stats2D.length]; double[] lower = new double[stats2D.length]; final CurveFitter<Parametric> fitter2D = new CurveFitter<Parametric>(new LevenbergMarquardtOptimizer()); final CurveFitter<Parametric> fitter3D = new CurveFitter<Parametric>(new LevenbergMarquardtOptimizer()); Statistics gradient2D = new Statistics(); Statistics gradient3D = new Statistics(); final int firstN = (useConfinement) ? fitN : totalSteps; for (int j = 0; j < totalSteps; j++) { // Convert steps to seconds xValues[j] = (double) (j + 1) / settings.stepsPerSecond; // Convert values in pixels^2 to um^2 final double mean = stats2D[j].getMean() / conversionFactor; final double sd = stats2D[j].getStandardDeviation() / conversionFactor; yValues2D[j] = mean; yValues3D[j] = stats3D[j].getMean() / conversionFactor; upper[j] = mean + sd; lower[j] = mean - sd; if (j < firstN) { fitter2D.addObservedPoint(xValues[j], yValues2D[j]); gradient2D.add(yValues2D[j] / xValues[j]); fitter3D.addObservedPoint(xValues[j], yValues3D[j]); gradient3D.add(yValues3D[j] / xValues[j]); } } // TODO - Fit using the equation for 2D confined diffusion: // MSD = 4s^2 + R^2 (1 - 0.99e^(-1.84^2 Dt / R^2) // s = localisation precision // R = confinement radius // D = 2D diffusion coefficient // t = time // Do linear regression to get diffusion rate final double[] init2D = { 0, 1 / gradient2D.getMean() }; // a - b x final double[] best2D = fitter2D.fit(new PolynomialFunction.Parametric(), init2D); final PolynomialFunction fitted2D = new PolynomialFunction(best2D); final double[] init3D = { 0, 1 / gradient3D.getMean() }; // a - b x final double[] best3D = fitter3D.fit(new PolynomialFunction.Parametric(), init3D); final PolynomialFunction fitted3D = new PolynomialFunction(best3D); // Create plot String title = TITLE; Plot2 plot = new Plot2(title, "Time (seconds)", "Mean-squared Distance (um^2)", xValues, yValues2D); double[] limits = Maths.limits(upper); limits = Maths.limits(limits, lower); limits = Maths.limits(limits, yValues3D); plot.setLimits(0, totalSteps / settings.stepsPerSecond, limits[0], limits[1]); plot.setColor(Color.blue); plot.addPoints(xValues, lower, Plot2.LINE); plot.addPoints(xValues, upper, Plot2.LINE); plot.setColor(Color.magenta); plot.addPoints(xValues, yValues3D, Plot2.LINE); plot.setColor(Color.red); plot.addPoints(new double[] { xValues[0], xValues[xValues.length - 1] }, new double[] { fitted2D.value(xValues[0]), fitted2D.value(xValues[xValues.length - 1]) }, Plot2.LINE); plot.setColor(Color.green); plot.addPoints(new double[] { xValues[0], xValues[xValues.length - 1] }, new double[] { fitted3D.value(xValues[0]), fitted3D.value(xValues[xValues.length - 1]) }, Plot2.LINE); plot.setColor(Color.black); Utils.display(title, plot); // For 2D diffusion: d^2 = 4D // where: d^2 = mean-square displacement double D = best2D[1] / 4.0; String msg = "2D Diffusion rate = " + Utils.rounded(D, 4) + " um^2 / sec (" + Utils.timeToString(time) + ")"; IJ.showStatus(msg); Utils.log(msg); D = best3D[1] / 6.0; Utils.log("3D Diffusion rate = " + Utils.rounded(D, 4) + " um^2 / sec (" + Utils.timeToString(time) + ")"); if (useConfinement) Utils.log("3D asymptote distance = %s nm (expected %.2f)", Utils.rounded(asymptote.getMean() * settings.pixelPitch, 4), 3 * settings.confinementRadius / 4); }
From source file:com.polivoto.vistas.acciones.Datos.java
private void setcolors() { colores.add(Color.red);/* www. j av a 2 s . c o m*/ colores.add(Color.green); colores.add(Color.blue); colores.add(Color.yellow); colores.add(Color.magenta); colores.add(Color.cyan); colores.add(Color.pink); colores.add(Color.orange); colores.add(Color.darkGray); colores.add(Color.white); }
From source file:HW3.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//ww w . j a v a2s . co m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { topPanel = new javax.swing.JPanel(); mainCategoryPanel = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); subCategoryPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); attrPanel = new javax.swing.JPanel(); jScrollPane5 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); dayLabel = new javax.swing.JLabel(); dayComboBox = new javax.swing.JComboBox(); fromLabel = new javax.swing.JLabel(); fromComboBox = new javax.swing.JComboBox(); toLabel = new javax.swing.JLabel(); toComboBox = new javax.swing.JComboBox(); searchLabel = new javax.swing.JLabel(); searchComboBox = new javax.swing.JComboBox(); searchButton = new javax.swing.JButton(); closeButton = new javax.swing.JButton(); cityComboBox = new javax.swing.JComboBox(); stateComboBox = new javax.swing.JComboBox(); zipComboBox = new javax.swing.JComboBox(); cityLabel = new javax.swing.JLabel(); stateLabel = new javax.swing.JLabel(); zipLabel = new javax.swing.JLabel(); clearButton = new javax.swing.JButton(); openCloseComboBox = new javax.swing.JComboBox(); openCloseLabel = new javax.swing.JLabel(); reviewPanel = new javax.swing.JPanel(); jScrollPane3 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); backButton = new javax.swing.JButton(); displayPiechartButton = new javax.swing.JButton(); displayBarchartButton = new javax.swing.JButton(); startButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("YELP SEARCH"); setBackground(new java.awt.Color(255, 255, 102)); setBounds(new java.awt.Rectangle(0, 0, 1000, 800)); setPreferredSize(new java.awt.Dimension(950, 710)); setResizable(false); topPanel.setBorder(javax.swing.BorderFactory.createCompoundBorder( javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4), new javax.swing.border.LineBorder(java.awt.Color.red, 2, true))); topPanel.setPreferredSize(new java.awt.Dimension(930, 700)); topPanel.setVisible(false); mainCategoryPanel.setBackground(new java.awt.Color(204, 204, 255)); mainCategoryPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.black, null)); mainCategoryPanel.setPreferredSize(new java.awt.Dimension(200, 300)); javax.swing.GroupLayout mainCategoryPanelLayout = new javax.swing.GroupLayout(mainCategoryPanel); mainCategoryPanel.setLayout(mainCategoryPanelLayout); mainCategoryPanelLayout.setHorizontalGroup(mainCategoryPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 171, Short.MAX_VALUE)); mainCategoryPanelLayout.setVerticalGroup(mainCategoryPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 496, Short.MAX_VALUE)); jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane2.setPreferredSize(new java.awt.Dimension(131, 280)); subCategoryPanel.setBackground(new java.awt.Color(204, 255, 255)); subCategoryPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.black, null)); javax.swing.GroupLayout subCategoryPanelLayout = new javax.swing.GroupLayout(subCategoryPanel); subCategoryPanel.setLayout(subCategoryPanelLayout); subCategoryPanelLayout.setHorizontalGroup(subCategoryPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); subCategoryPanelLayout.setVerticalGroup(subCategoryPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jScrollPane2.setViewportView(subCategoryPanel); jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane1.setPreferredSize(new java.awt.Dimension(131, 280)); attrPanel.setBackground(new java.awt.Color(255, 255, 204)); attrPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.black, null)); javax.swing.GroupLayout attrPanelLayout = new javax.swing.GroupLayout(attrPanel); attrPanel.setLayout(attrPanelLayout); attrPanelLayout.setHorizontalGroup(attrPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); attrPanelLayout.setVerticalGroup(attrPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jScrollPane1.setViewportView(attrPanel); jScrollPane5.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jScrollPane5.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane5.setPreferredSize(new java.awt.Dimension(131, 280)); jTable2.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.black, null)); jTable2.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Business_Name", "City", "State", "Stars", "Business_ID", "Zip" })); jTable2.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); jTable2.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { jTable2MousePressed(evt); } }); jScrollPane5.setViewportView(jTable2); dayLabel.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N dayLabel.setForeground(java.awt.Color.red); dayLabel.setText("Day of the week"); dayLabel.setToolTipText(""); dayComboBox.setBackground(java.awt.Color.magenta); dayComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" })); dayComboBox.setSelectedIndex(-1); dayComboBox.setToolTipText("Please select the day"); dayComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { dayComboBoxActionPerformed(evt); } }); fromLabel.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N fromLabel.setForeground(java.awt.Color.red); fromLabel.setText("From:"); fromComboBox.setBackground(java.awt.Color.magenta); fromComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00" })); fromComboBox.setSelectedIndex(-1); fromComboBox.setToolTipText("Please select the start time"); toLabel.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N toLabel.setForeground(java.awt.Color.red); toLabel.setText("To:"); toComboBox.setBackground(java.awt.Color.magenta); toComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00" })); toComboBox.setSelectedIndex(-1); toComboBox.setToolTipText("Please select the end time"); searchLabel.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N searchLabel.setForeground(java.awt.Color.red); searchLabel.setText("Search For"); searchComboBox.setBackground(java.awt.Color.magenta); searchComboBox.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "Any attributes", "All attributes" })); searchComboBox.setSelectedIndex(-1); searchComboBox.setToolTipText("Please select the attributes"); searchButton.setBackground(new java.awt.Color(255, 255, 0)); searchButton.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N searchButton.setForeground(java.awt.Color.blue); searchButton.setText("SEARCH"); searchButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchButtonActionPerformed(evt); } }); closeButton.setBackground(new java.awt.Color(102, 255, 102)); closeButton.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N closeButton.setForeground(java.awt.Color.blue); closeButton.setText("CLOSE"); closeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeButtonActionPerformed(evt); } }); cityComboBox.setBackground(java.awt.Color.magenta); cityComboBox.setToolTipText("Please select city"); stateComboBox.setBackground(java.awt.Color.magenta); stateComboBox.setToolTipText("Please select state"); stateComboBox.setSelectedIndex(-1); zipComboBox.setBackground(java.awt.Color.magenta); zipComboBox.setToolTipText("Please select zip"); zipComboBox.setSelectedIndex(-1); cityLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N cityLabel.setForeground(java.awt.Color.red); cityLabel.setText("City"); stateLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N stateLabel.setForeground(java.awt.Color.red); stateLabel.setText("State"); zipLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N zipLabel.setForeground(java.awt.Color.red); zipLabel.setText("Zip"); clearButton.setBackground(new java.awt.Color(255, 255, 51)); clearButton.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N clearButton.setForeground(java.awt.Color.blue); clearButton.setText("CLEAR COMBO_BOXES"); clearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearButtonActionPerformed(evt); } }); openCloseComboBox.setBackground(java.awt.Color.magenta); openCloseComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "open", "close" })); openCloseComboBox.setSelectedIndex(-1); openCloseLabel.setForeground(java.awt.Color.red); openCloseLabel.setText("OPEN OR CLOSE day"); javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel); topPanel.setLayout(topPanelLayout); topPanelLayout.setHorizontalGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup().addGap(16, 16, 16).addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(mainCategoryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, topPanelLayout.createSequentialGroup().addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(topPanelLayout.createSequentialGroup().addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(dayLabel) .addComponent(dayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(fromLabel).addComponent(fromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addGap(1, 1, 1).addComponent(toLabel)) .addComponent(toComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addGap(10, 10, 10).addComponent(searchComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, topPanelLayout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(searchLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cityComboBox, 0, 95, Short.MAX_VALUE) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(cityLabel) .addGap(0, 0, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(stateLabel).addGap(18, 18, 18)) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(stateComboBox, 0, 54, Short.MAX_VALUE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(zipComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zipLabel)) .addGap(18, 18, 18).addComponent(searchButton) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(closeButton)) .addGroup(topPanelLayout.createSequentialGroup().addGap(10, 10, 10) .addComponent(openCloseLabel).addGap(18, 18, 18) .addComponent(openCloseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(17, 17, 17))))); topPanelLayout .setVerticalGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(topPanelLayout .createSequentialGroup().addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup().addGap(17, 17, 17) .addComponent(mainCategoryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(topPanelLayout .createSequentialGroup().addContainerGap().addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(dayLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(2, 2, 2).addComponent(dayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(topPanelLayout.createSequentialGroup().addGap(5, 5, 5) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(fromLabel).addGap(2, 2, 2) .addComponent(fromComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(topPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(openCloseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(openCloseLabel)) .addGap(5, 5, 5)) .addGroup(topPanelLayout.createSequentialGroup() .addGroup(topPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(clearButton, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)) .addGroup(topPanelLayout.createSequentialGroup() .addGroup(topPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout .createSequentialGroup() .addComponent(toLabel) .addGap(2, 2, 2) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(toComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( searchComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cityComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(stateComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(zipComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(topPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(searchLabel) .addComponent(cityLabel) .addComponent(stateLabel) .addComponent(zipLabel))) .addGap(0, 0, Short.MAX_VALUE))))))); reviewPanel.setVisible(false); reviewPanel.setBorder(javax.swing.BorderFactory.createCompoundBorder( javax.swing.BorderFactory.createLineBorder(java.awt.Color.red, 4), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2))); reviewPanel.setPreferredSize(new java.awt.Dimension(800, 600)); jTable1.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.black, null)); jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Review Date", "Stars", "Review Text", "User ID", "Useful Votes", "Cool Votes", "Funny Votes" })); jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); jTable1.setPreferredSize(new java.awt.Dimension(800, 600)); jScrollPane3.setViewportView(jTable1); jScrollPane3.setVisible(false); backButton.setBackground(new java.awt.Color(255, 255, 0)); backButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N backButton.setText("BACK"); backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backButtonActionPerformed(evt); } }); displayPiechartButton.setBackground(new java.awt.Color(255, 255, 51)); displayPiechartButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N displayPiechartButton.setText("DISPLAY PIECHART FOR REVIEW STAR"); displayPiechartButton.setToolTipText("Please select this to display piechart of review stars."); displayPiechartButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { displayPiechartButtonActionPerformed(evt); } }); displayBarchartButton.setBackground(new java.awt.Color(255, 255, 51)); displayBarchartButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N displayBarchartButton.setText("BARGRAPH TOP 5 USEFUL REVIEWS"); displayBarchartButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { displayBarchartButtonActionPerformed(evt); } }); javax.swing.GroupLayout reviewPanelLayout = new javax.swing.GroupLayout(reviewPanel); reviewPanel.setLayout(reviewPanelLayout); reviewPanelLayout.setHorizontalGroup(reviewPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(reviewPanelLayout.createSequentialGroup() .addGroup(reviewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 703, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(reviewPanelLayout.createSequentialGroup() .addComponent(displayPiechartButton, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(displayBarchartButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(backButton))) .addGap(20, 20, 20))); reviewPanelLayout.setVerticalGroup(reviewPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(reviewPanelLayout.createSequentialGroup() .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(reviewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(displayBarchartButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(reviewPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(displayPiechartButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(20, 20, 20))); startButton.setBackground(new java.awt.Color(255, 255, 51)); startButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N startButton.setForeground(new java.awt.Color(51, 51, 255)); startButton.setText("START"); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(10, 10, 10).addComponent( topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGap(61, 61, 61).addComponent( startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 686, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(118, Short.MAX_VALUE) .addComponent(reviewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 726, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(156, Short.MAX_VALUE)))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 616, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(21, Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(42, Short.MAX_VALUE) .addComponent(reviewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(41, Short.MAX_VALUE)))); pack(); }