/** * Constructs a plot frame for the specified plot panel. * @param panel the plot panel. */ public PlotFrame(PlotPanel panel) { _panelTL = panel; _panelBR = panel; _panelMain = new MainPanel(); _panelMain.setLayout(new BorderLayout()); _panelMain.add(_panelTL,BorderLayout.CENTER); this.setSize(_panelMain.getPreferredSize()); this.add(_panelMain,BorderLayout.CENTER); this.setFont(DEFAULT_FONT); this.setBackground(DEFAULT_BACKGROUND); this.setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT); addModeManager(); addResizedShownListener(); }
public void run() { paintToPng(fdpi,fwin,ffileName); } });
/** * Sets font size automatically for a slide in presentations. * This method causes the font size to change as this frame is resized, * so that text height will be about 1/25 of slide height if this frame * is saved to an image. * Specified fractions indicate indicate how much of the slide is * available for this plot. These fractions may be less than one, * to leave room for titles, other plots, etc. * <p> * This method uses a default width/height aspect ratio = 4.0/3.0. * To explicitly specify the aspect ratio, use the method * {@link #setFontSizeForSlide(double,double,double)}. * @param fracWidth the fraction of slide width available. * @param fracHeight the fraction of slide height available. */ public void setFontSizeForSlide(double fracWidth, double fracHeight) { setFontSizeForSlide(fracWidth,fracHeight,4.0/3.0); }
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"); } }
_plotFrame = new PlotFrame(_plotPanel); TileZoomMode tzm = _plotFrame.getTileZoomMode(); ModeManager mm = _plotFrame.getModeManager(); PoleZeroMode pm = new PoleZeroMode(mm,true); // for poles PoleZeroMode zm = new PoleZeroMode(mm,false); // for zeros menuBar.add(fileMenu); menuBar.add(modeMenu); _plotFrame.setJMenuBar(menuBar); toolBar.add(new ModeToggleButton(pm)); toolBar.add(new ModeToggleButton(zm)); _plotFrame.add(toolBar,BorderLayout.WEST); _plotFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); _plotFrame.setLocation(PZP_X,PZP_Y); _plotFrame.setSize(PZP_WIDTH,PZP_HEIGHT); _plotFrame.setFontSizeForPrint(8,240); _plotFrame.setVisible(true);
_plotFrame = new PlotFrame( _plotPanelH,_plotPanelAP,PlotFrame.Split.VERTICAL); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); _plotFrame.setJMenuBar(menuBar); _plotFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); _plotFrame.setLocation(RP_X,RP_Y); _plotFrame.setSize(RP_WIDTH,RP_HEIGHT); _plotFrame.setFontSizeForPrint(8,240); _plotFrame.setVisible(true);
panel.setHLabel(1,"Velocity (km/s)"); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); int type = 2; 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"); frame.setVisible(true); frame.paintToPng(720,3.333333,"junk.png");
PlotFrame frame = new PlotFrame(panel1,panel2,PlotFrame.Split.HORIZONTAL); frame.setTitle("Example Contour Plot"); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.add(jsp,BorderLayout.NORTH); frame.pack(); frame.setVisible(true);
PlotFrame frame = new PlotFrame(plot); frame.setFontSize(18); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true);
pv1b.setPercentiles(0.0f,100.0f); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true);
private void addResizedShownListener() { this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { adjustFontSize(); } public void componentShown(ComponentEvent e) { adjustFontSize(); } }); } private void adjustFontSize() {
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); }
plot.setClips(0.0f,1.0f); PlotFrame frame = new PlotFrame(plot); frame.setFontSize(18); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true);
pv1b.setClips(2,0.0f,2.0f); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true);
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); } }
_splitPane.setOneTouchExpandable(true); _panelMain.add(_splitPane,BorderLayout.CENTER); this.setSize(_panelMain.getPreferredSize()); this.add(_panelMain,BorderLayout.CENTER); this.setBackground(DEFAULT_BACKGROUND); this.setFont(DEFAULT_FONT); this.setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT); addModeManager(); addResizedShownListener();
public void actionPerformed(ActionEvent event) { JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.showSaveDialog(_plotFrame); File file = fc.getSelectedFile(); if (file!=null) { String filename = file.getAbsolutePath(); _plotFrame.paintToPng(300,6,filename); } } }
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"); } }
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); }
PlotFrame frame = new PlotFrame(plot); frame.add(buttPanel,BorderLayout.SOUTH); frame.setSize(600,500); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true);