/** * Adds the color bar with no label. The color bar paints the color map * of the most recently added pixels view. To avoid confusion, a color * bar should perhaps not be added when this plot panel contains multiple * pixels views with different color maps.. * @return the color bar. */ public ColorBar addColorBar() { return addColorBar(null,null); }
/** * Adds a contours view of the specified sampled function f(x1,x2). * @param s1 the sampling of the variable x1; must be uniform. * @param s2 the sampling of the variable x2; must be uniform. * @param f array[n2][n1] of sampled function values f(x1,x2), where * n1 = f[0].length and n2 = f.length. * @return the contours view. */ public ContoursView addContours(Sampling s1, Sampling s2, float[][] f) { return addContours(0,0,s1,s2,f); }
/** * Removes the color bar. */ public void removeColorBar() { if (_colorBar!=null) { remove(_colorBar); revalidate(); _colorBar = null; } }
private PoleZeroPlot() { _plotPanel = new PlotPanel(); _plotPanel.setTitle("poles and zeros"); _plotPanel.setHLabel("real"); _plotPanel.setVLabel("imaginary"); _plotPanel.setHLimits(-2.0,2.0); _plotPanel.setVLimits(-2.0,2.0); _plotPanel.addGrid("H0-V0-"); _circleView = _plotPanel.addPoints(circlePoints[0],circlePoints[1]); _circleView.setLineColor(Color.RED);
PlotPanel panel = new PlotPanel(1,2,orientation); PixelsView pxv0 = panel.addPixels(0,0,s1,s2,f); PixelsView pxv1 = panel.addPixels(0,1,s1,s2,f); pxv0.setColorModel(ColorMap.GRAY); pxv1.setColorModel(ColorMap.JET); PointsView ptv0 = panel.addPoints(0,0,x1,x2); PointsView ptv1 = panel.addPoints(0,1,x1,x2); ptv0.setStyle("r--."); ptv1.setStyle("k-o"); panel.addColorBar("Amplitude"); panel.setVLabel("Depth (km)"); panel.setHLabel(0,"Offset (km)"); panel.setHLabel(1,"Velocity (km/s)"); if (type==0) { frame.setFontSize(24); panel.setTitle("Graphic with 24-pt font"); } else if (type==1) { frame.setFontSizeForPrint(8,240); panel.setTitle("Graphic for print"); } else if (type==2) { frame.setFontSizeForSlide(1,1); panel.setTitle("Graphic for slide");
public PlotFrameDemo() { float[] x = rampfloat(0.0f,4.0f*FLT_PI/200.0f,201); float[] s = sin(x); _plotPanel = new PlotPanel(); _plotPanel.setTitle("The sine function"); _plotPanel.setHLabel("x"); _plotPanel.setVLabel("sin(x)"); _gridView = _plotPanel.addGrid(); _pointsView = _plotPanel.addPoints(x,s); _pointsView.setStyle("r-o"); _plotFrame = new PlotFrame(_plotPanel); _plotFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); _plotFrame.setVisible(true); _plotFrame.add( new Label("In either plot or axes, click-drag to zoom, click to unzoom."), BorderLayout.NORTH); }
_plotPanelH = new PlotPanel(); _plotPanelH.setHLabel("sample index"); _plotPanelH.setVLabel("amplitude"); _plotPanelH.setTitle("impulse response"); _plotPanelAP = new PlotPanel(2,1); _plotPanelAP.setTitle("amplitude and phase response"); if (_db) { _plotPanelAP.setVLabel(0,"amplitude (dB)"); } else { _plotPanelAP.setVLabel(0,"amplitude"); _plotPanelAP.setVLimits(1,-0.5,0.5); _plotPanelAP.setVLabel(1,"phase (cycles)"); _plotPanelAP.setHLabel("frequency (cycles/sample)");
private static void plot(TriMesh tm) { TriMeshView tmv = new TriMeshView(tm); tmv.setPolysVisible(true); tmv.setTriColor(Color.BLACK); tmv.setPolyColor(Color.BLUE); PlotPanel panel = new PlotPanel(); panel.setHLabel("x"); panel.setVLabel("y"); Mosaic mosaic = panel.getMosaic(); mosaic.getTile(0,0).addTiledView(tmv); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(700,700); frame.setVisible(true); } }
array[i][j] = (float)(i+j)*(i-j); PlotPanel panel1 = new PlotPanel(); PlotPanel panel2 = new PlotPanel(); JPanel topLeftPanel = new JPanel(); JPanel topRightPanel = new JPanel(); topRightPanel.setLayout(new GridLayout(2,2)); final ContoursView cv1 = panel1.addContours(array); cv1.setLineStyleNegative(ContoursView.Line.DASH); cv1.setLineColor(Color.BLACK); cv1.setContours(50); final PixelsView pv2 = panel2.addPixels(array); final ContoursView cv2 = panel2.addContours(array); panel2.addColorBar(); PlotFrame frame = new PlotFrame(panel1,panel2,PlotFrame.Split.HORIZONTAL); frame.setTitle("Example Contour Plot");
if (_title==null) { _title = new Title(title); Font font = getFont(); font.deriveFont(1.5f*font.getSize2D()); _title.setFont(getFont()); _title.setForeground(getForeground()); _title.setBackground(getBackground()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; add(_title,gbc); revalidate(); } else { _title.set(title); remove(_title); revalidate(); _title = null;
public static void main(String args[]) { System.out.println("LogAxisPlotDemo2"); int n = 1000; float X = 300; float[] x = ArrayMath.rampfloat(0.0f,X / n,n); float[] f = new float[n]; for (int i = 0; i < n; ++i) { f[i] = pow(1.5f * x[i],2); } // new plot PlotPanel plot = new PlotPanel(2,2); pv1 = plot.addPoints(0,0,x,f); pv2 = plot.addPoints(0,1,x,f); pv3 = plot.addPoints(1,0,x,f); pv4 = plot.addPoints(1,1,x,f); // frame setup plot.setVisible(true); PlotFrame frame = new PlotFrame(plot); frame.setSize(800,500); frame.add(makeScaleOptionPanel(),BorderLayout.EAST); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
private static void demo1() { int n = 50; float[] x1 = randfloat(n); float[] x2 = randfloat(n); float[] x3 = randfloat(n); PlotPanel panel = new PlotPanel(1,1); panel.setLimits(-0.1,-0.1,1.1,1.1); PointsView pv = panel.addPoints(x1,x2,x3); pv.setLineStyle(PointsView.Line.NONE); pv.setMarkStyle(PointsView.Mark.FILLED_CIRCLE); pv.setTextFormat("%4.2f"); PlotFrame frame = new PlotFrame(panel); frame.setSize(800,800); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true); //frame.paintToPng(300,6,"junk.png"); } }
/** * Adds a points view of the arrays x1 and x2 of point (x1,x2) coordinates. * @param x1 array of x1 coordinates. * @param x2 array of x2 coordinates. * @return the points view. */ public PointsView addPoints(float[] x1, float[] x2) { return addPoints(0,0,x1,x2); }
/** * Sets default limits for the horizontal axis in the specified column. * This method may be used to restore default limits after they have * been set explicitly. * @param icol the column index. */ public void setHLimitsDefault(int icol) { int nrow = getMosaic().countRows(); for (int irow=0; irow<nrow; ++irow) getTile(irow,icol).setHLimitsDefault(); }
Sampling s2 = new Sampling(n2,0.5,0.25*(n2-1)); PlotPanel panel = new PlotPanel(1,2); PixelsView pv0 = panel.addPixels(0,0,f); pv0.setInterpolation(PixelsView.Interpolation.NEAREST); pv0.setColorModel(ColorMap.JET); pv0.set(f); PixelsView pv0b = panel.addPixels(0,0,s1,s2,f); pv0b.setInterpolation(PixelsView.Interpolation.LINEAR); pv0b.setColorModel(ColorMap.GRAY); pv0b.setPercentiles(0.0f,100.0f); PixelsView pv1 = panel.addPixels(0,1,f); pv1.setInterpolation(PixelsView.Interpolation.LINEAR); pv1.setColorModel(ColorMap.GRAY); pv1.set(f); PixelsView pv1b = panel.addPixels(0,1,s1,s2,f); pv1b.setInterpolation(PixelsView.Interpolation.NEAREST); pv1b.setColorModel(ColorMap.JET);
/** * Adds a pixels view of the specified sampled function f(x1,x2). * @param s1 the sampling of the variable x1; must be uniform. * @param s2 the sampling of the variable x2; must be uniform. * @param f array[n2][n1] of sampled function values f(x1,x2), where * n1 = f[0].length and n2 = f.length. * @return the pixels view. */ public PixelsView addPixels(Sampling s1, Sampling s2, float[][] f) { return _panel.addPixels(s1,s2,f); }
private static void go() { int nx = 101; float dx = 0.1f; float fx = -0.5f*dx*(float)(nx-1); Sampling sx = new Sampling(nx,dx,fx); float[] f1 = rampfloat(fx,dx,nx); float[] f2 = add(0.5f,sin(f1)); PlotPanel panel = new PlotPanel(2,1); SequenceView sv1 = panel.addSequence(0,0,sx,f1); sv1.setColor(Color.RED); SequenceView sv2 = panel.addSequence(1,0,sx,f2); sv2.setZero(SequenceView.Zero.MIDDLE); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setSize(950,500); frame.setVisible(true); frame.paintToPng(300,6,"junk.png"); } }
private void updateViews() { Real1 h = computeImpulseResponse(); Real1[] ap = computeAmplitudeAndPhaseResponses(); Real1 a = ap[0]; Real1 p = ap[1]; if (_hView==null) { _hView = _plotPanelH.addSequence(h.getSampling(),h.getValues()); _aView = _plotPanelAP.addPoints(0,0,a.getSampling(),a.getValues()); _pView = _plotPanelAP.addPoints(1,0,p.getSampling(),p.getValues()); } else { _hView.set(h.getSampling(),h.getValues()); _aView.set(a.getSampling(),a.getValues()); _pView.set(p.getSampling(),p.getValues()); } }