当前位置: 首页>>代码示例>>Java>>正文


Java InteractivePanel类代码示例

本文整理汇总了Java中org.opensourcephysics.display.InteractivePanel的典型用法代码示例。如果您正苦于以下问题:Java InteractivePanel类的具体用法?Java InteractivePanel怎么用?Java InteractivePanel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InteractivePanel类属于org.opensourcephysics.display包,在下文中一共展示了InteractivePanel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMouseAction

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
public void handleMouseAction(InteractivePanel panel, MouseEvent evt) {
  int id = -1;
  if(panel.getMouseAction()==InteractivePanel.MOUSE_PRESSED) {
    //do nothing                
  }
  if(panel.getMouseAction()==InteractivePanel.MOUSE_DRAGGED) {
    double x = panel.getMouseX();
    double y = panel.getMouseY();
    id = MouseOnCurve(x, y);
    System.out.println(id+"\t"+x+"\t"+y);
    if((x>0)&&(y>0)) {
      drawCurve(id, x, y);
    }
  }
  if(panel.getMouseAction()==InteractivePanel.MOUSE_RELEASED) {
    plotFrame.setMessage("");
  }
}
 
开发者ID:OpenSourcePhysics,项目名称:STP,代码行数:19,代码来源:CarnotApp.java

示例2: handleMouseAction

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
public void handleMouseAction(InteractivePanel panel, MouseEvent evt) {
  if(panel.getMouseAction()==InteractivePanel.MOUSE_PRESSED) {
    double s = MouseOnCurve(panel.getMouseX(), panel.getMouseY());
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(3);
    if(s!=Double.MIN_VALUE) {
      String str = "";
      switch(cid) {
         case 0 :
           str = "T = ";
           break;
         case 1 :
           str = "Ta = ";
           plotFrame.setMessage(str+nf.format(s));
           break;
         case 2 :
           str = "Tb = ";
           plotFrame.setMessage(str+nf.format(s));
           break;
      }
    }
  }
  if(panel.getMouseAction()==InteractivePanel.MOUSE_RELEASED) {
    plotFrame.setMessage("");
  }
}
 
开发者ID:OpenSourcePhysics,项目名称:STP,代码行数:27,代码来源:EntropyApp.java

示例3: getCoordinateString

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Converts a the pixel coordinates in a mouse event into world coordinates and
 * return these coordinates in a string.
 *
 * @param e the mouse event
 * @return the coordinate string
 */
public String getCoordinateString(DrawingPanel panel, MouseEvent e) {
  double x = panel.pixToX(e.getPoint().x);
  double y = panel.pixToY(e.getPoint().y);
  if((panel instanceof InteractivePanel)&&((InteractivePanel) panel).getCurrentDraggable()!=null) {
    x = ((InteractivePanel) panel).getCurrentDraggable().getX();
    y = ((InteractivePanel) panel).getCurrentDraggable().getY();
  }
  String msg = ""; //$NON-NLS-1$
  if((Math.abs(x)>100)||(Math.abs(x)<0.01)||(Math.abs(y)>100)||(Math.abs(y)<0.01)) {
    if(xLabel!=null) {
      msg = xLabel+scientificFormat.format((float) x);
    }
    if(yLabel!=null) {
      msg += yLabel+scientificFormat.format((float) y);
    }
  } else {
    if(xLabel!=null) {
      msg = xLabel+decimalFormat.format((float) x);
    }
    if(yLabel!=null) {
      msg += yLabel+decimalFormat.format((float) y);
    }
  }
  return msg;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:33,代码来源:CartesianCoordinateStringBuilder.java

示例4: getCoordinateString

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Converts a the pixel coordinates in a mouse event into world coordinates and
 * return these coordinates in a string.
 *
 * @param e the mouse event
 * @return the coordinate string
 */
public String getCoordinateString(DrawingPanel panel, MouseEvent e) {
  double x = panel.pixToX(e.getPoint().x);
  double y = panel.pixToY(e.getPoint().y);
  if((panel instanceof InteractivePanel)&&((InteractivePanel) panel).getCurrentDraggable()!=null) {
    x = ((InteractivePanel) panel).getCurrentDraggable().getX();
    y = ((InteractivePanel) panel).getCurrentDraggable().getY();
  }
  double r = Math.sqrt(x*x+y*y);
  String msg;
  if((r>100)||(r<0.01)) {
    msg = rLabel+scientificFormat.format((float) r);
  } else {
    msg = rLabel+decimalFormat.format((float) r);
  }
  msg += phiLabel+decimalFormat.format(180*(float) Math.atan2(x*sin+y*cos, x*cos-y*sin)/Math.PI);
  return msg;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:25,代码来源:PolarCoordinateStringBuilder.java

示例5: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Shows the color associated with each value.
 * @return the JFrame containing the legend
 */
public JFrame showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  CellLattice lattice = new CellLattice(256, 1);
  lattice.setMinMax(-128, 127, 0, 1);
  byte[][] data = new byte[256][1];
  for(int i = 0; i<256; i++) {
    data[i][0] = (byte) (-128+i);
  }
  lattice.setBlock(0, 0, data);
  dp.addDrawable(lattice);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:33,代码来源:SiteLattice.java

示例6: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
public JFrame showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  int numColors = 256;
  GridPointData pointdata = new GridPointData(numColors, 1, 1);
  double[][][] data = pointdata.getData();
  double delta = (ceil-floor)/(numColors);
  double cval = floor-delta/2;
  for(int i = 0, n = data.length; i<n; i++) {
    double c = cval;
    if(zMap!=null) {
      c = zMap.evaluate(c);
    }
    data[i][0][2] = c;
    cval += delta;
  }
  pointdata.setScale(floor-delta, ceil+delta, 0, 1);
  GrayscalePlot cb = new GrayscalePlot(pointdata);
  cb.setShowGridLines(false);
  cb.setAutoscaleZ(false, floor, ceil);
  cb.update();
  dp.addDrawable(cb);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:40,代码来源:GrayscalePlot.java

示例7: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
public JFrame showLegend() {
  double floor = 0;
  double ceil = this.ceil*2;
  legendPanel = new InteractivePanel();
  legendPanel.setPreferredSize(new java.awt.Dimension(300, 120));
  legendPanel.setPreferredGutters(0, 0, 0, 35);
  legendPanel.setClipAtGutter(false);
  legendPanel.setSquareAspect(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(true);
  legendFrame.setContentPane(legendPanel);
  int numVecs = 30;
  GridPointData pointdata = new GridPointData(numVecs, 2, 3);
  double[][][] data = pointdata.getData();
  double delta = 1.5*ceil/numVecs;
  double cval = floor-delta/2;
  for(int i = 0, n = data.length; i<n; i++) {
    data[i][1][2] = cval;
    data[i][1][3] = 0;
    data[i][1][4] = 4;
    cval += delta;
  }
  pointdata.setScale(0, 1.5*ceil+delta, 0, 1);
  legendPlot = new VectorPlot(pointdata);
  legendPlot.setPaletteType(paletteType);
  legendPlot.setAutoscaleZ(false, 0.5*ceil, ceil);
  legendPlot.update();
  legendPanel.addDrawable(legendPlot);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.0);
  xaxis.setEnabled(true);
  legendPanel.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:41,代码来源:VectorColorMapper.java

示例8: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Shows the color legend.
 */
public JFrame showLegend() {
  if(zMap!=null) {
    return showLegend(zMap);
  }
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  GridPointData pointdata = new GridPointData(numColors+2, 1, 1);
  double[][][] data = pointdata.getData();
  double delta = (ceil-floor)/(numColors);
  double cval = floor-delta/2;
  for(int i = 0, n = data.length; i<n; i++) {
    data[i][0][2] = cval;
    cval += delta;
  }
  pointdata.setScale(floor-delta, ceil+delta, 0, 1);
  GridPlot cb = new GridPlot(pointdata);
  cb.setShowGridLines(false);
  cb.setAutoscaleZ(false, floor, ceil);
  cb.setColorPalette(colors);
  cb.update();
  dp.addDrawable(cb);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:42,代码来源:ColorMapper.java

示例9: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Shows the color associated with each value.
 * @return the JFrame containing the legend
 */
public JFrame showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  CellLattice lattice = new CellLattice(256, 1);
  lattice.setMinMax(-128, 127, 0, 1);
  byte[][] data = new byte[256][1];
  for(int i = 0; i<256; i++) {
    data[i][0] = (byte) (-128+i);
  }
  lattice.setBlock(0, 0, data);
  Color[] colors = new Color[256];
  for(int i = 0; i<256; i++) {
    colors[i] = new Color(rgb[i][0], rgb[i][1], rgb[i][2]);
  }
  lattice.setColorPalette(colors);
  dp.addDrawable(lattice);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:38,代码来源:CellLatticePC.java

示例10: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Shows the color associated with each value.
 */
public JFrame showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 80));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  ByteRaster byteRaster = new ByteRaster(256, 20);
  byteRaster.setMinMax(-128, 127, 0, 1);
  byte[][] data = new byte[256][20];
  for(int i = 0; i<256; i++) {
    for(int j = 0; j<20; j++) {
      data[i][j] = (byte) (-128+i);
    }
  }
  byteRaster.setBlock(0, 0, data);
  Color[] colors = new Color[256];
  for(int i = 0; i<256; i++) {
    colors[(128+i)%256] = new Color((256+reds[i])%256, (256+greens[i])%256, (256+blues[i])%256);
  }
  byteRaster.setColorPalette(colors);
  dp.addDrawable(byteRaster);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:39,代码来源:ByteRaster.java

示例11: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**  Shows the color associated with each value. */
public void showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame(DisplayRes.getString("GUIUtils.Legend")); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  TriangularByteLattice lattice = new TriangularByteLattice(1, 256);
  lattice.setMinMax(-128, 127, 0, 1);
  byte[][] data = new byte[1][256];
  for(int i = 0; i<256; i++) {
    data[0][i] = (byte) i;
  }
  lattice.setBlock(0, 0, data);
  dp.addDrawable(lattice);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:29,代码来源:TriangularByteLattice.java

示例12: showPhaseLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
public static JFrame showPhaseLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  JFrame legendFrame = new JFrame("Complex Phase"); //$NON-NLS-1$
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  int numPts = 360;
  GridPointData pointdata = new GridPointData(numPts, 1, 3);
  double[][][] data = pointdata.getData();
  double theta = -Math.PI, delta = 2*Math.PI/(numPts);
  for(int i = 0, n = data.length; i<n; i++) {
    data[i][0][2] = 0.999;
    data[i][0][3] = Math.cos(theta);
    data[i][0][4] = Math.sin(theta);
    theta += delta;
  }
  pointdata.setScale(-Math.PI, Math.PI, 0, 1);
  Plot2D plot = new ComplexGridPlot(pointdata);
  plot.setShowGridLines(false);
  plot.update();
  dp.addDrawable(plot);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:33,代码来源:ComplexColorMapper.java

示例13: showLegend

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Shows the phase legend.
 */
public JFrame showLegend() {
  InteractivePanel dp = new InteractivePanel();
  dp.setPreferredSize(new java.awt.Dimension(300, 66));
  dp.setPreferredGutters(0, 0, 0, 35);
  dp.setClipAtGutter(false);
  if((legendFrame==null)||!legendFrame.isDisplayable()) {
    legendFrame = new JFrame("Complex Phase"); //$NON-NLS-1$
  }
  legendFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  legendFrame.setResizable(false);
  legendFrame.setContentPane(dp);
  int numPts = 360;
  GridPointData pointdata = new GridPointData(numPts, 1, 3);
  double[][][] data = pointdata.getData();
  double theta = -Math.PI, delta = 2*Math.PI/(numPts);
  for(int i = 0, n = data.length; i<n; i++) {
    data[i][0][2] = 0.999;
    data[i][0][3] = Math.cos(theta);
    data[i][0][4] = Math.sin(theta);
    theta += delta;
  }
  pointdata.setScale(-Math.PI, Math.PI, 0, 1);
  Plot2D plot = new ComplexGridPlot(pointdata);
  plot.setShowGridLines(false);
  plot.update();
  dp.addDrawable(plot);
  XAxis xaxis = new XAxis(""); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setLocation(-0.5);
  xaxis.setEnabled(true);
  dp.addDrawable(xaxis);
  legendFrame.pack();
  legendFrame.setVisible(true);
  return legendFrame;
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:39,代码来源:ComplexColorMapper.java

示例14: Vector2DFrame

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Constructs a Vector2DFrame with the given frame title but without axes.
 * @param frameTitle String
 */
public Vector2DFrame(String frameTitle) {
  super(new InteractivePanel());
  setTitle(frameTitle);
  plot.setShowGridLines(false);
  drawingPanel.addDrawable(plot);
  addMenuItems();
  setAnimated(true);
  setAutoclear(true);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:14,代码来源:Vector2DFrame.java

示例15: FFT2DFrame

import org.opensourcephysics.display.InteractivePanel; //导入依赖的package包/类
/**
 * Constructs a Complex2DFrame with the given frame title but without axes.
 * @param frameTitle String
 */
public FFT2DFrame(String frameTitle) {
  super(new InteractivePanel());
  setTitle(frameTitle);
  drawingPanel.addDrawable(plot);
  addMenuItems();
  setAnimated(true);
  setAutoclear(true);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:13,代码来源:FFT2DFrame.java


注:本文中的org.opensourcephysics.display.InteractivePanel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。