コード例 #1
0
ファイル: TagPanel.java プロジェクト: kinuxroot/tagging
 public AxisPanel getAxisPanelByName(String axis) {
   AxisPanel ap = null;
   for (AxisPanel p : axisPanels) {
     if (p.getAxis().equals(axis)) {
       ap = p;
     }
   }
   return ap;
 }
コード例 #2
0
  public void updateGUI() {

    btBackgroundColor.setForeground(view.getBackground());
    btAxesColor.setForeground(view.getAxesColor());
    btGridColor.setForeground(view.getGridColor());

    cbShowAxes.removeActionListener(this);
    cbShowAxes.setSelected(view.getShowXaxis() && view.getShowYaxis());
    cbShowAxes.addActionListener(this);

    cbShowGrid.removeActionListener(this);
    cbShowGrid.setSelected(view.getShowGrid());
    cbShowGrid.addActionListener(this);

    //      Michael Borcherds 2008-04-11
    cbBoldGrid.removeActionListener(this);
    cbBoldGrid.setSelected(view.getGridIsBold());
    cbBoldGrid.addActionListener(this);

    cbShowMouseCoords.removeActionListener(this);
    cbShowMouseCoords.setSelected(view.getAllowShowMouseCoords());
    cbShowMouseCoords.addActionListener(this);

    cbView.removeActionListener(this);
    if (view == app.getEuclidianView()) cbView.setSelectedIndex(0);
    else cbView.setSelectedIndex(1);
    cbView.addActionListener(this);

    tfMinX.removeActionListener(this);
    tfMaxX.removeActionListener(this);
    tfMinY.removeActionListener(this);
    tfMaxY.removeActionListener(this);
    tfMinX.setText(kernel.format(view.getXmin()));
    tfMaxX.setText(kernel.format(view.getXmax()));
    tfMinY.setText(kernel.format(view.getYmin()));
    tfMaxY.setText(kernel.format(view.getYmax()));
    tfMinX.addActionListener(this);
    tfMaxX.addActionListener(this);
    tfMinY.addActionListener(this);
    tfMaxY.addActionListener(this);

    cbGridType.removeActionListener(this);
    cbGridType.setSelectedIndex(view.getGridType());
    cbGridType.addActionListener(this);

    cbAxesStyle.removeActionListener(this);
    cbAxesStyle.setSelectedIndex(view.getAxesLineStyle());
    cbAxesStyle.addActionListener(this);

    cbGridStyle.removeActionListener(this);
    int type = view.getGridLineStyle();
    for (int i = 0; i < cbGridStyle.getItemCount(); i++) {
      if (type == ((Integer) cbGridStyle.getItemAt(i)).intValue()) {
        cbGridStyle.setSelectedIndex(i);
        break;
      }
    }
    cbGridStyle.addActionListener(this);

    cbGridManualTick.removeActionListener(this);
    boolean autoGrid = view.isAutomaticGridDistance();
    cbGridManualTick.setSelected(!autoGrid);
    cbGridManualTick.addActionListener(this);

    ncbGridTickX.removeItemListener(this);
    ncbGridTickY.removeItemListener(this);
    cbGridTickAngle.removeItemListener(this);
    double[] gridTicks = view.getGridDistances();

    if (view.getGridType() != EuclidianView.GRID_POLAR) {

      ncbGridTickY.setVisible(true);
      gridLabel2.setVisible(true);
      cbGridTickAngle.setVisible(false);
      gridLabel3.setVisible(false);

      ncbGridTickX.setValue(gridTicks[0]);
      ncbGridTickY.setValue(gridTicks[1]);
      gridLabel1.setText("x:");

    } else {
      ncbGridTickY.setVisible(false);
      gridLabel2.setVisible(false);
      cbGridTickAngle.setVisible(true);
      gridLabel3.setVisible(true);

      ncbGridTickX.setValue(gridTicks[0]);
      int val = (int) (view.getGridDistances(2) * 12 / Math.PI) - 1;
      if (val == 5) val = 4; // handle Pi/2 problem
      cbGridTickAngle.setSelectedIndex(val);
      gridLabel1.setText("r:");
    }

    ncbGridTickX.setEnabled(!autoGrid);
    ncbGridTickY.setEnabled(!autoGrid);
    cbGridTickAngle.setEnabled(!autoGrid);
    ncbGridTickX.addItemListener(this);
    ncbGridTickY.addItemListener(this);
    cbGridTickAngle.addItemListener(this);

    tfAxesRatioX.removeActionListener(this);
    tfAxesRatioY.removeActionListener(this);
    double xscale = view.getXscale();
    double yscale = view.getYscale();
    if (xscale >= yscale) {
      tfAxesRatioX.setText("1");
      tfAxesRatioY.setText(nfAxesRatio.format(xscale / yscale));
    } else {
      tfAxesRatioX.setText(nfAxesRatio.format(yscale / xscale));
      tfAxesRatioY.setText("1");
    }
    tfAxesRatioX.addActionListener(this);
    tfAxesRatioY.addActionListener(this);

    xAxisPanel.updatePanel();
    yAxisPanel.updatePanel();
  }