Example #1
0
  private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            Setting.getString("/bat/isotope/graph/bg/title"), // chart title
            Setting.getString("/bat/isotope/graph/bg/x_axes"), // x axis label
            Setting.getString("/bat/isotope/graph/bg/y_axes"), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
            );

    chart.setBackgroundPaint(Setting.getColor("/bat/isotope/graph/background"));
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setRangeGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().getUpperBound();
    plot.setDataset(1, Func.xYSlope(slope, plot.getDomainAxis().getUpperBound()));

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseSeriesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setSeriesItemLabelFont(0, fText);
    renderer.setBaseItemLabelFont(fText);
    chart.getTitle().setFont(fTitel);

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);

    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(true);
    axis.setLabelFont(fAxes);
    plot.getDomainAxis().setLabelFont(fAxes);

    return chart;
  }
Example #2
0
  public static void LoadDefaults() {
    try {
      Settings.globals.load(
          new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt"));
    } catch (FileNotFoundException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    } catch (InvalidConfigurationException e1) {
      e1.printStackTrace();
    }

    for (String i :
        new String[] {
          "Zombie",
          "Skeleton",
          "Creeper",
          "Spider",
          "Ghast",
          "Slime",
          "ZombiePigman",
          "Giant",
          "TamedWolf",
          "WildWolf",
          "ElectrifiedCreeper",
          "Player",
          "Enderman",
          "Silverfish",
          "CaveSpider",
          "EnderDragon",
          "MagmaCube",
          "Blaze"
        }) {
      if (Settings.globals.get("Value." + i) != null) continue;

      Settings.globals.set("Value." + i + ".General", 10);
      Settings.globals.set("Value." + i + ".Wolf", 7);
      Settings.globals.set("Value." + i + ".Arrow", 4);
      Settings.globals.set("Value." + i + ".Snowball", 20);
      Settings.globals.set("Value." + i + ".283", 20);
    }

    for (String i :
        new String[] {
          "MushroomCow", "Chicken", "Cow", "Pig", "Sheep", "SnowGolem", "Squid", "Villager"
        }) {
      if (Settings.globals.get("Value." + i) != null) continue;

      Settings.globals.set("Value." + i + ".General", 0);
    }

    if (!new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt")
        .exists()) {
      Settings.globals.set("MinimumPointsPlace1", 1);
      Settings.globals.set("MinimumPointsPlace2", 1);
      Settings.globals.set("MinimumPointsPlace3", 1);
      Settings.globals.set("Rewards.RewardParametersPlace1", "3 3");
      Settings.globals.set("Rewards.RewardParametersPlace2", "3 2");
      Settings.globals.set("Rewards.RewardParametersPlace3", "3 1");
    }

    for (Setting s : Setting.values()) {
      if (s.writeDefault() && Settings.globals.get(s.getString()) == null)
        Settings.globals.set(s.getString(), s.getDefault());
    }

    try {
      Settings.globals.save(
          new File("plugins" + File.separator + "MonsterHunt" + File.separator, "global.txt"));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Example #3
0
  /**
   * @param main
   * @param type
   */
  public GraphIso2(Bats main, String type) {
    this.main = main;
    this.data = main.data;
    h1 = Setting.getInt("/bat/general/font/h1");
    p = Setting.getInt("/bat/general/font/p");
    ft = Setting.getString("/bat/general/font/type");
    fTitel = new Font(ft, Font.PLAIN, h1);
    fAxes = new Font(ft, Font.PLAIN, p);
    fText = new Font(ft, Font.PLAIN, p);
    x = Setting.getString("/bat/isotope/graph/" + type + "/x_value");
    y = Setting.getString("/bat/isotope/graph/" + type + "/y_value");
    dataType = Setting.getString("/bat/isotope/graph/" + type + "/data");
    try {
      x_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/x_value")
              .getAttribute("multi")
              .getIntValue();
      y_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/y_value")
              .getAttribute("multi")
              .getIntValue();
    } catch (DataConversionException e) {
      x_multi = 1;
      y_multi = 1;
    }

    JLabel textLabel = new JLabel("Isobar correction on radioisotope:", JLabel.LEFT);
    textLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);

    JLabel textLabel2 =
        new JLabel(Setting.getString("/bat/isotope/graph/" + type + "/unit"), JLabel.LEFT);
    textLabel2.setAlignmentX(Component.RIGHT_ALIGNMENT);

    nf.setOverwriteMode(false);
    nf.setMinimum(0.000);
    textField = new JFormattedTextField(nf);
    try {
      textField.setValue(data.corrList.get(0).isoFact);
    } catch (IndexOutOfBoundsException e) {
      log.debug("Could not set isobar factor.");
    }
    textField.setColumns(5); // get some space

    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField.selectAll();
                } else
                  try { // The text is valid,
                    textField.commitEdit(); // so use it.
                    fieldChange();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    textField2 = new JFormattedTextField(nf);
    textField2.setValue(data.corrList.get(0).isoErr);
    textField2.setColumns(5); // get some space

    textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField2
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField2.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField2.selectAll();
                } else
                  try { // The text is valid,
                    textField2.commitEdit(); // so use it.
                    fieldChange2();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    JPanel labelAndText = new JPanel();
    labelAndText.add(textLabel);
    labelAndText.add(textField);
    labelAndText.add(new JLabel("±"));
    labelAndText.add(textField2);
    labelAndText.add(textLabel2);

    JPanel regPane = new JPanel();
    regPane.add(new JLabel("slope: "));
    NumberFormatter nf = new NumberFormatter(new DecimalFormat("0.00E00"));
    slopeField = new JFormattedTextField(nf);
    slopeField.setPreferredSize(new Dimension(80, 20));
    slopeField.setEditable(false);
    regPane.add(slopeField);
    slopeErrField = new JFormattedTextField(nf);
    slopeErrField.setPreferredSize(new Dimension(80, 20));
    slopeErrField.setEditable(false);
    regPane.add(slopeErrField);
    regPane.add(new JLabel("R^2: "));
    nf = new NumberFormatter(new DecimalFormat("0.00E0"));
    rField = new JFormattedTextField(nf);
    rField.setPreferredSize(new Dimension(60, 20));
    rField.setEditable(false);
    regPane.add(rField);
    this.makeReg();

    JPanel regTextPanel = new JPanel(new GridLayout(1, 2));
    regTextPanel.add(labelAndText);
    regTextPanel.add(regPane);

    JPanel controlPanel = new JPanel(new GridLayout(1, 1));
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.PAGE_AXIS));
    controlPanel.setBorder(BorderFactory.createEmptyBorder(30, 10, 5, 10));
    controlPanel.add(regTextPanel);

    JDialog frame = new JDialog();
    frame.setModal(true);
    frame.setTitle("Correction");
    frame.setPreferredSize(
        new Dimension(
            Setting.getInt("/bat/general/frame/correction/width"),
            Setting.getInt("/bat/general/frame/correction/height")));
    frame.add(controlPanel, BorderLayout.SOUTH);
    dataSet = Func.getXY(data.get(dataType), null, x, y, x_multi, y_multi);
    chart = createChart(dataSet);
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(this);
    frame.pack();
    frame.setVisible(true);
  }