Ejemplo n.º 1
0
  @Override
  protected void addCustomMetadata(Product product) throws IOException {
    // add bitmasks for ATSR active fires, see http://dup.esrin.esa.it/ionia/wfa/algorithm.asp
    final String nadirBand = EnvisatConstants.AATSR_L1B_BTEMP_NADIR_0370_BAND_NAME;
    final String fwardBand = EnvisatConstants.AATSR_L1B_BTEMP_FWARD_0370_BAND_NAME;

    ProductNodeGroup<Mask> maskGroup = product.getMaskGroup();
    if (product.containsBand(nadirBand)) {
      maskGroup.add(
          mask(
              "fire_nadir_1", "ATSR active fire (ALGO1)", nadirBand + " > 312.0", Color.RED, 0.5f));
      maskGroup.add(
          mask(
              "fire_nadir_2",
              "ATSR active fire (ALGO2)",
              nadirBand + " > 308.0",
              Color.RED.darker(),
              0.5f));
    }
    if (product.containsBand(fwardBand)) {
      maskGroup.add(
          mask(
              "fire_fward_1", "ATSR active fire (ALGO1)", fwardBand + " > 312.0", Color.RED, 0.5f));
      maskGroup.add(
          mask(
              "fire_fward_2",
              "ATSR active fire (ALGO2)",
              fwardBand + " > 308.0",
              Color.RED.darker(),
              0.5f));
    }
  }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   Robot Maria = new Robot("batman");
   Maria.setWindowColor(Color.RED.darker());
   Maria.setPenColor(Color.white);
   Maria.penDown();
   Maria.sparkle();
   for (int i = 0; i < 4; i++) {
     Maria.move(50);
     Maria.turn(90);
   }
 }
Ejemplo n.º 3
0
  private void paintHelyxProgressBar(Graphics g) {
    int leftPadding = 15;
    int topPadding = 205;
    int splashWidth = getSplashScreen().getSize().width;
    int width = Math.min(10 * counter, splashWidth - (leftPadding * 2));

    g.setColor(isHelyxOS ? Color.BLUE.darker() : Color.RED.darker());
    g.fillRect(leftPadding, topPadding, width, 2);
    g.setColor(isHelyxOS ? Color.BLUE.brighter() : Color.RED.brighter());
    g.fillRect(leftPadding, topPadding, width, 1);
  }
Ejemplo n.º 4
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   synchronized (clicks) {
     g2.setColor(Color.RED.darker());
     for (Ellipse2D ellipse : clicks) {
       g2.fill(ellipse);
     }
   }
   g2.setColor(Color.GREEN.darker());
   synchronized (points) {
     for (Ellipse2D ellipse : points.values()) {
       g2.fill(ellipse);
     }
   }
 }
Ejemplo n.º 5
0
 @Override
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   final MagicDeck deck = (MagicDeck) value;
   final Component c =
       super.getListCellRendererComponent(list, deck.getName(), index, isSelected, cellHasFocus);
   if (deck.isValid() == false) {
     if (invalidDeckFont == null) {
       final Map<TextAttribute, Object> attributes = new HashMap<>();
       attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
       invalidDeckFont = c.getFont().deriveFont(attributes);
     }
     c.setFont(invalidDeckFont);
     c.setForeground(isSelected ? list.getSelectionForeground() : Color.RED.darker());
   }
   return c;
 }
Ejemplo n.º 6
0
    void updateView(TicketItemModifier ticketItemModifier) {
      if (ticketItemModifier == null
          || ticketItemModifier.getModifierType() == TicketItemModifier.MODIFIER_NOT_INITIALIZED) {
        setBackground(null);
        // setIcon(null);
        return;
      }

      if (ticketItemModifier.getModifierType() == TicketItemModifier.NORMAL_MODIFIER) {
        // setIcon(normalIcon);
        setBackground(Color.GREEN.darker());
      } else if (ticketItemModifier.getModifierType() == TicketItemModifier.NO_MODIFIER) {
        // setIcon(noIcon);
        setBackground(Color.RED.darker());
      } else if (ticketItemModifier.getModifierType() == TicketItemModifier.EXTRA_MODIFIER) {
        // setIcon(extraIcon);
        setBackground(Color.ORANGE);
      }
    }
Ejemplo n.º 7
0
 public void wdgmsg(Widget sender, String msg, Object... args) {
   if (sender == in) {
     if (args[0] != null || ((String) args[0]).length() > 0) {
       String cmdText = ((String) args[0]).trim().toUpperCase();
       String cmd =
           cmdText.contains(" ") ? cmdText.substring(0, cmdText.indexOf(" ")).trim() : cmdText;
       cmdText = cmdText.contains(" ") ? cmdText.substring(cmdText.indexOf(" ")).trim() : "";
       append("Command: " + cmd + "\nArguments: " + cmdText, Color.BLUE.darker());
       String[] cmdArgs = cmdText.split(" ");
       in.settext("");
       if (cmd.equals("NIGHTVISION")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE"))
             CustomConfig.hasNightVision = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.hasNightVision = false;
         } else {
           append("NIGHTVISION - " + (CustomConfig.hasNightVision ? "ON" : "OFF"));
         }
       } else if (cmd.equals("IRC")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) CustomConfig.isIRCOn = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.isIRCOn = false;
         } else {
           append("IRC - " + (CustomConfig.isIRCOn ? "ON" : "OFF"));
         }
       }
       if (cmd.equals("SCREENSIZE") || cmd.equals("WINDOWSIZE")) {
         if (!cmdArgs[0].trim().equals("") && cmdArgs.length >= 2) {
           try {
             int x = Integer.parseInt(cmdArgs[0]);
             int y = Integer.parseInt(cmdArgs[1]);
             if (x >= 800 && y >= 600) {
               CustomConfig.setWindowSize(x, y);
             }
             CustomConfig.saveSettings();
             append(
                 "Client must be restarted for new settings to take effect.", Color.RED.darker());
           } catch (NumberFormatException e) {
             append("Dimensions must be numbers");
           }
         } else {
           append("SCREENSIZE = " + CustomConfig.windowSize.toString());
         }
       } else if (cmd.equals("SOUND")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isSoundOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isSoundOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.sfxVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "SOUND = "
                   + (CustomConfig.isSoundOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.sfxVol);
         }
       } else if (cmd.equals("MUSIC")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isMusicOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isMusicOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.musicVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "MUSIC = "
                   + (CustomConfig.isMusicOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.musicVol);
         }
       } else if (cmd.equals("SAVE")) {
         CustomConfig.saveSettings();
       } else if (cmd.equals("FORCESAVE")) {
         CustomConfig.isSaveable = true;
         CustomConfig.saveSettings();
       } else if (cmd.equals("DEBUG")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("IRC")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logIRC = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logIRC = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
             }
           } else if (cmdArgs[0].equals("SRVMSG")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logServerMessages = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logServerMessages = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append(
                   "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
                   Color.GREEN.darker());
             }
           }
           if (cmdArgs[0].equals("LOAD")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logLoad = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logLoad = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
             }
           }
         } else {
           append("DEBUG LOGS", Color.BLUE.darker());
           append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
           append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
           append(
               "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
               Color.GREEN.darker());
         }
       } else if (cmd.equals("HELP")) {
         append(
             "You can check the current status of each variable by "
                 + "typing the command without arguments.",
             Color.RED.darker());
         append("NIGHTVISION TRUE | FALSE | ON | OFF - Turns nightvision on or off");
         append("SCREENSIZE #### #### - Sets the screensize to the specified size.");
         append(
             "SOUND TRUE | FALSE | ON | OFF | 0-100 - Turns the sound effects on/off, or sets "
                 + "the volume to the specified level");
         append(
             "MUSIC TRUE | FALSE | ON | OFF | 0-100 - Turns the music on/off, or sets "
                 + "the volume to the specified level");
         append("SAVE - Saves the current settings if they are saveable.");
         append(
             "FORCESAVE - Saves the current settings whether or not they are "
                 + "saveable (Might cause errors).");
         append(
             "DEBUG IRC | LOAD   ON | OFF - Enables/disables debug text being dumped into the console "
                 + "for the specified system.");
         append("HELP - Shows this text.");
       } else {
         append("Command not recognized.  Type /help to see a list of commands.");
       }
     }
   } else {
     super.wdgmsg(sender, msg, args);
   }
 }
 @Override
 protected void initConfig(WordsWithStyle wordsReservedLanguague) {
   /** ******************************************************** */
   StyleHTML styleHTML = new StyleHTML();
   styleHTML.setColor(Color.BLUE);
   styleHTML.setFontStyle(Font.ITALIC);
   styleHTML.setUnderline(true);
   wordsReservedLanguague.put("\\balgoritmo\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimalgoritmo\\b", styleHTML);
   wordsReservedLanguague.put("\\bvar\\b", styleHTML);
   wordsReservedLanguague.put("\\bdos\\b", styleHTML);
   wordsReservedLanguague.put("\\binicio\\b", styleHTML);
   wordsReservedLanguague.put("\\bprocedimento\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimprocedimento\\b", styleHTML);
   wordsReservedLanguague.put("\\bfuncao\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimfuncao\\b", styleHTML);
   /** ******************************************************** */
   StyleHTML styleComments = new StyleHTML();
   styleComments.setColor(Color.GREEN.darker().darker());
   styleComments.setFontStyle(Font.ITALIC);
   wordsReservedLanguague.put("(?m)//.*$", styleComments);
   /** ******************************************************** */
   StyleHTML styleCommentsMultine = new StyleHTML();
   styleCommentsMultine.setColor(Color.BLUE.brighter());
   styleCommentsMultine.setFontStyle(Font.BOLD);
   wordsReservedLanguague.put("(?m)\\/\\*[\\s\\S]*?\\*\\/", styleCommentsMultine);
   /** ******************************************************** */
   StyleHTML styleString = new StyleHTML();
   styleString.setColor(Color.RED);
   wordsReservedLanguague.put("\\\"(?:\\.|(\\\\\\\")|[^\\\"\\\"\n])*\\\"", styleString);
   wordsReservedLanguague.put("\\'(?:\\.|(\\\\\\')|[^\\'\\'\n])*\\'", styleString);
   /** ******************************************************** */
   StyleHTML styleNumber = new StyleHTML();
   styleNumber.setColor(Color.RED);
   wordsReservedLanguague.put("\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b", styleNumber);
   wordsReservedLanguague.put("\\bfalso\\b", styleNumber);
   wordsReservedLanguague.put("\\bverdadeiro\\b", styleNumber);
   /** ******************************************************** */
   StyleHTML styleTypes = new StyleHTML();
   styleTypes.setColor(Color.RED.darker().darker().darker());
   styleTypes.setUnderline(true);
   wordsReservedLanguague.put("\\binteiro\\b", styleTypes);
   wordsReservedLanguague.put("\\breal\\b", styleTypes);
   wordsReservedLanguague.put("\\bcaractere\\b", styleTypes);
   wordsReservedLanguague.put("\\bcaracter\\b", styleTypes);
   wordsReservedLanguague.put("\\blogico\\b", styleTypes);
   wordsReservedLanguague.put("\\bvetor\\b", styleTypes);
   /** ******************************************************** */
   StyleHTML styleCode = new StyleHTML();
   styleCode.setColor(Color.BLUE.darker().darker());
   wordsReservedLanguague.put("\\bescreva\\b", styleCode);
   wordsReservedLanguague.put("\\bescreval\\b", styleCode);
   wordsReservedLanguague.put("\\bleia\\b", styleCode);
   wordsReservedLanguague.put("\\bse\\b", styleCode);
   wordsReservedLanguague.put("\\bentao\\b", styleCode);
   wordsReservedLanguague.put("\\bsenao\\b", styleCode);
   wordsReservedLanguague.put("\\bfimse\\b", styleCode);
   wordsReservedLanguague.put("\\bescolha\\b", styleCode);
   wordsReservedLanguague.put("\\bfimescolha\\b", styleCode);
   wordsReservedLanguague.put("\\bcaso\\b", styleCode);
   wordsReservedLanguague.put("\\boutrocaso\\b", styleCode);
   wordsReservedLanguague.put("\\bate\\b", styleCode);
   wordsReservedLanguague.put("\\bde\\b", styleCode);
   wordsReservedLanguague.put("\\bfaca\\b", styleCode);
   wordsReservedLanguague.put("\\bpara\\b", styleCode);
   wordsReservedLanguague.put("\\bfimpara\\b", styleCode);
   wordsReservedLanguague.put("\\bdiv\\b", styleCode);
   wordsReservedLanguague.put("\\brepita\\b", styleCode);
   /** ******************************************************** */
 }
  /**
   * A private constructor to create a new editor frame based on the specified prefs configuration.
   *
   * @param prefs: the configuration to use.
   */
  private PreferencesGUIEditorFrame(final ClientPreferences prefs) {
    super("Crystal Configuration Editor");
    Assert.assertNotNull(prefs);

    final ClientPreferences copyPrefs = prefs.clone();
    final Map<JComponent, Boolean> changedComponents = new HashMap<JComponent, Boolean>();
    final Map<JTextField, Boolean> validEditorText = new HashMap<JTextField, Boolean>();
    final Map<ProjectPreferences, Map<JTextField, Boolean>> validTextSet =
        new HashMap<ProjectPreferences, Map<JTextField, Boolean>>();
    final JFrame frame = this;
    frame.setIconImage(
        (new ImageIcon(
                Constants.class.getResource("/crystal/client/images/crystal-ball_blue_128.png")))
            .getImage());

    if (copyPrefs.getProjectPreference().isEmpty()) {
      // ClientPreferences client = new ClientPreferences("/usr/bin/hg/", "/tmp/crystalClient/");
      ProjectPreferences newGuy =
          new ProjectPreferences(
              new DataSource("", "", DataSource.RepoKind.HG, false, null), copyPrefs);
      try {
        copyPrefs.addProjectPreferences(newGuy);
        copyPrefs.setChanged(true);
      } catch (DuplicateProjectNameException e) {
        // Just ignore the duplicate project name
      }
    }

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

    //		getContentPane().add(new JLabel("Closing this window will save the configuraion
    // settings."));

    //		JPanel hgPanel = new JPanel();
    //		hgPanel.setLayout(new BoxLayout(hgPanel, BoxLayout.X_AXIS));
    //		hgPanel.add(new JLabel("Path to hg executable:"));
    //		final JTextField hgPath = new JTextField(prefs.getHgPath());
    // hgPath.setSize(hgPath.getWidth(), 16);
    //		hgPanel.add(hgPath);
    //		hgPath.addKeyListener(new KeyListener() {
    //			public void keyPressed(KeyEvent arg0) {
    //			}
    //
    //			public void keyTyped(KeyEvent arg0) {
    //			}
    //
    //			public void keyReleased(KeyEvent arg0) {
    //				prefs.setHgPath(hgPath.getText());
    //				prefs.setChanged(true);
    //				frame.pack();
    //			}
    //		});
    //
    //		JButton hgButton = new JButton("find");
    //		hgPanel.add(hgButton);
    //		hgButton.addActionListener(new ActionListener() {
    //			public void actionPerformed(ActionEvent e) {
    //				new MyPathChooser("Path to hg executable", hgPath, JFileChooser.FILES_ONLY);
    //				prefs.setChanged(true);
    //			}
    //		});
    //		getContentPane().add(hgPanel);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new SpringLayout());

    for (int i = 0; i < 2; i++) {
      topPanel.add(new JLabel());
    }

    topPanel.add(new JLabel("Valid?"));

    JPanel tempPanel = new JPanel();
    tempPanel.setLayout(new BoxLayout(tempPanel, BoxLayout.X_AXIS));
    topPanel.add(new JLabel("Path to scratch space: "));

    final JTextField tempPath = new JTextField(copyPrefs.getTempDirectory());
    final JLabel tempPathState = new JLabel();
    tempPanel.add(tempPath);

    changedComponents.put(tempPath, false);
    boolean pathValid =
        ValidInputChecker.checkDirectoryPath(tempPath.getText())
            || ValidInputChecker.checkUrl(tempPath.getText());
    if (pathValid) {
      tempPathState.setText("  valid");
      tempPathState.setForeground(Color.GREEN.darker());
    } else {
      tempPathState.setText("invalid");
      tempPathState.setForeground(Color.RED.darker());
    }
    validEditorText.put(tempPath, pathValid);

    tempPath.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent arg0) {}

          public void keyTyped(KeyEvent arg0) {}

          public void keyReleased(KeyEvent arg0) {
            // TODO check if text is valid text
            copyPrefs.setTempDirectory(tempPath.getText());
            changedComponents.put(tempPath, !prefs.getTempDirectory().equals(tempPath.getText()));

            boolean pathValid =
                ValidInputChecker.checkDirectoryPath(tempPath.getText())
                    || ValidInputChecker.checkUrl(tempPath.getText());
            validEditorText.put(tempPath, pathValid);
            if (pathValid) {
              tempPathState.setText("  valid");
              tempPathState.setForeground(Color.GREEN.darker());
            } else {
              tempPathState.setText("invalid");
              tempPathState.setForeground(Color.RED.darker());
            }
            // copyPrefs.setChanged(true);
            frame.pack();
          }
        });

    tempPath.addFocusListener(
        new FocusListener() {

          @Override
          public void focusGained(FocusEvent arg0) {
            tempPath.selectAll();
          }

          @Override
          public void focusLost(FocusEvent arg0) {}
        });
    JButton tempButton = new JButton("find");
    tempPanel.add(tempButton);
    tempButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new MyPathChooser("Path to scratch directory", tempPath, JFileChooser.DIRECTORIES_ONLY);
            // copyPrefs.setChanged(true);
          }
        });

    topPanel.add(tempPanel);
    topPanel.add(tempPathState);

    topPanel.add(new JLabel("Refresh rate: "));

    final JTextField refreshRate = new JTextField(String.valueOf(copyPrefs.getRefresh()));
    final JLabel rateState = new JLabel("  valid");
    rateState.setForeground(Color.GREEN.darker());
    topPanel.add(refreshRate);
    topPanel.add(rateState);
    changedComponents.put(refreshRate, false);
    validEditorText.put(refreshRate, true);

    refreshRate.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent arg0) {}

          public void keyTyped(KeyEvent arg0) {}

          public void keyReleased(KeyEvent arg0) {

            changedComponents.put(
                refreshRate, !String.valueOf(prefs.getRefresh()).equals(refreshRate.getText()));
            try {
              copyPrefs.setRefresh(Long.valueOf(refreshRate.getText()));
            } catch (Exception e) {

            }
            boolean valid = ValidInputChecker.checkStringToLong(refreshRate.getText());
            validEditorText.put(refreshRate, valid);

            if (valid) {
              rateState.setText("  valid");
              rateState.setForeground(Color.GREEN.darker());
            } else {
              rateState.setText("invalid");
              rateState.setForeground(Color.RED.darker());
            }
            // copyPrefs.setChanged(true);
          }
        });

    SpringLayoutUtility.formGridInColumn(topPanel, 3, 3);
    getContentPane().add(topPanel);

    final JTabbedPane projectsTabs =
        new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    /*
     * projectsTabs.addChangeListener(new ChangeListener() {
     *
     * @Override public void stateChanged(ChangeEvent e) { frame.pack(); System.out.println("Tabs changed"); } });
     */

    for (final ProjectPreferences copyPref : copyPrefs.getProjectPreference()) {
      ProjectPanel current;
      try {
        Map<JTextField, Boolean> validPanel = new HashMap<JTextField, Boolean>();
        validTextSet.put(copyPref, validPanel);
        current =
            new ProjectPanel(
                copyPref,
                copyPrefs,
                frame,
                projectsTabs,
                changedComponents,
                prefs.getProjectPreferences(copyPref.getName()),
                validPanel);
        projectsTabs.addTab(current.getName(), current);
        JPanel pnl = new JPanel();
        JLabel tabName = new JLabel(current.getName());
        pnl.setOpaque(false);
        pnl.add(tabName);
        pnl.add(
            new DeleteProjectButton(
                copyPrefs, projectsTabs, frame, current, copyPref, validTextSet));
        projectsTabs.setTabComponentAt(projectsTabs.getTabCount() - 1, pnl);
        // projectsTabs.setTitleAt(projectsTabs.getTabCount() - 1, current.getName());
      } catch (NonexistentProjectException e1) {
        // never happens
      }
    }

    final JButton newProjectButton = new JButton("Add New Project");
    // final JButton deleteProjectButton = new JButton("Delete This Project");

    newProjectButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // deleteProjectButton.setEnabled(true);
            HashSet<String> shortNameLookup = new HashSet<String>();
            for (ProjectPreferences current : copyPrefs.getProjectPreference()) {
              shortNameLookup.add(current.getName());
            }
            int count = 1;
            while (shortNameLookup.contains("New_Project_" + count++)) ;

            final ProjectPreferences newGuy =
                new ProjectPreferences(
                    new DataSource(
                        "New_Project_" + --count, "", DataSource.RepoKind.HG, false, null),
                    copyPrefs);
            try {
              copyPrefs.addProjectPreferences(newGuy);
            } catch (DuplicateProjectNameException e1) {
              // This should never happen because we just found a clean project name to use.
              throw new RuntimeException(
                  "When I tried to create a new project, I found a nice, clean, unused name:\n"
                      + "New_Project_"
                      + count
                      + "\nbut then the preferences told me that name was in use.  \n"
                      + "This should never happen!");
            }
            Map<JTextField, Boolean> validPanel = new HashMap<JTextField, Boolean>();
            validTextSet.put(newGuy, validPanel);
            final ProjectPanel newGuyPanel =
                new ProjectPanel(
                    newGuy, copyPrefs, frame, projectsTabs, changedComponents, null, validPanel);
            projectsTabs.addTab("New_Project_" + count, newGuyPanel);
            JPanel pnl = new JPanel();
            JLabel tabName = new JLabel(newGuy.getName());

            pnl.setOpaque(false);
            pnl.add(tabName);
            pnl.add(
                new DeleteProjectButton(
                    copyPrefs, projectsTabs, frame, newGuyPanel, newGuy, validTextSet));
            projectsTabs.setTabComponentAt(projectsTabs.getTabCount() - 1, pnl);
            projectsTabs.setSelectedIndex(projectsTabs.getTabCount() - 1);
            copyPrefs.setChanged(true);
            frame.pack();
          }
        });

    /*
    deleteProjectButton.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    		int current = projectsTabs.getSelectedIndex();
    		int option = JOptionPane.showConfirmDialog(null, "Do you want to delete project \"" + projectsTabs.getTitleAt(current) + "\"?",
    				"Empty cache", JOptionPane.YES_NO_OPTION);
    		// TODO wait for the current refresh to finish or kill it
    		if(option == JOptionPane.YES_OPTION) {
    			prefs.removeProjectPreferencesAtIndex(current);
    			projectsTabs.remove(current);
    			if (prefs.getProjectPreference().isEmpty())
    				deleteProjectButton.setEnabled(false);
    			prefs.setChanged(true);
    			frame.pack();
    		}
    	}
    });
    */

    getContentPane().add(newProjectButton);
    getContentPane().add(projectsTabs);
    // getContentPane().add(deleteProjectButton);

    JPanel savePanel = new JPanel();
    savePanel.setLayout(new FlowLayout());
    final JButton saveButton = new JButton("Save");
    final JButton cancelButton = new JButton("Cancel");
    savePanel.add(saveButton);
    savePanel.add(cancelButton);
    getContentPane().add(savePanel);

    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (copyPrefs.hasChanged() || changedComponents.values().contains(true)) {
              boolean validPanelText = true;
              for (Map<JTextField, Boolean> map : validTextSet.values()) {
                if (map.values().contains(false)) {
                  validPanelText = false;
                }
              }
              if (!validEditorText.values().contains(false) && validPanelText) {
                try {
                  ClientPreferences.savePreferencesToDefaultXML(copyPrefs);
                } catch (FileNotFoundException fnfe) {
                  _log.error("Could not write to the configuration file. " + fnfe);
                }
                // TODO
                copyPrefs.setChanged(false);
                frame.setVisible(false);
              } else {
                JOptionPane.showMessageDialog(
                    null, "You have invalid input.", "Warning", JOptionPane.ERROR_MESSAGE);
              }
            } else {

              frame.setVisible(false);
            }
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editorFrame = new PreferencesGUIEditorFrame(prefs);
            copyPrefs.setChanged(false);
            frame.setVisible(false);
          }
        });

    addWindowListener(
        new WindowListener() {
          public void windowClosing(WindowEvent arg0) {
            setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            if (copyPrefs.hasChanged() || changedComponents.values().contains(true)) {
              int n =
                  JOptionPane.showConfirmDialog(
                      null,
                      "Do you want to save your data?",
                      "Saving data",
                      JOptionPane.YES_NO_CANCEL_OPTION);
              if (n == JOptionPane.YES_OPTION) {

                boolean validPanelText = true;
                for (Map<JTextField, Boolean> map : validTextSet.values()) {
                  if (map.values().contains(false)) {
                    validPanelText = false;
                  }
                }
                if (!validEditorText.values().contains(false) && validPanelText) {
                  try {
                    ClientPreferences.savePreferencesToDefaultXML(copyPrefs);
                  } catch (FileNotFoundException fnfe) {
                    _log.error("Could not write to the configuration file. " + fnfe);
                  }
                  // TODO
                  copyPrefs.setChanged(false);
                } else {
                  JOptionPane.showMessageDialog(
                      null, "You have invalid input.", "Warning", JOptionPane.ERROR_MESSAGE);
                  setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                }
              } else if (n == JOptionPane.CANCEL_OPTION) {
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              } else { // option is no
                editorFrame = new PreferencesGUIEditorFrame(prefs);
                copyPrefs.setChanged(false);
              }
            }
          }

          public void windowActivated(WindowEvent arg0) {}

          public void windowClosed(WindowEvent arg0) {}

          public void windowDeactivated(WindowEvent arg0) {
            // Reload the preferences
            ConflictSystemTray.getInstance().loadPreferences();
          }

          public void windowDeiconified(WindowEvent arg0) {}

          public void windowIconified(WindowEvent arg0) {}

          public void windowOpened(WindowEvent arg0) {}
        });

    pack();
    // setVisible(true);
  }
Ejemplo n.º 10
0
/**
 * Attribute values for the nodes and edges.
 *
 * @author Arend rensink
 * @version $Revision $
 */
public class Values {
  /** Dash pattern of absent graphs and transitions. */
  public static final float[] ABSENT_DASH = new float[] {3.0f, 3.0f};
  /** Dash pattern of abstract type nodes and edges. */
  public static final float[] ABSTRACT_DASH = new float[] {6.0f, 2.0f};
  /** Dash pattern of connect edges. */
  public static final float[] CONNECT_DASH = new float[] {2f, 4f};
  /** Dash pattern for verdict edges. */
  public static final float[] VERDICT_DASH = new float[] {4.0f, 3.0f};
  /** No dash pattern. */
  public static final float[] NO_DASH = new float[] {10.f, 0.f};
  /** Foreground colour of creator nodes and edges. */
  public static final Color CREATOR_FOREGROUND = Color.green.darker();
  /** Background colour of creator nodes and edges. */
  public static final Color CREATOR_BACKGROUND = null;
  /** The default foreground colour used for edges and nodes. */
  public static final Color DEFAULT_FOREGROUND = Color.black;
  /** The default background colour used for nodes. */
  public static final Color DEFAULT_BACKGROUND = Colors.findColor("243 243 243");
  /** Dash pattern of embargo nodes and edges. */
  public static final float[] EMBARGO_DASH = new float[] {2f, 2f};
  /** Foreground colour of embargo nodes and edges. */
  public static final Color EMBARGO_FOREGROUND = Color.RED;
  /** Background colour of embargo nodes and edges. */
  public static final Color EMBARGO_BACKGROUND = null;
  /** Dash pattern of eraser nodes and edges. */
  public static final float[] ERASER_DASH = new float[] {4f, 4f};
  /** Foreground colour of eraser nodes and edges. */
  public static final Color ERASER_FOREGROUND = Color.BLUE;
  /** Background colour of eraser nodes and edges. */
  public static final Color ERASER_BACKGROUND = Colors.findColor("200 240 255");
  /** Dash pattern of nesting nodes and edges. */
  public static final float[] NESTED_DASH = new float[] {2.0f, 3.0f};
  /** Colour used for nesting nodes and states. */
  public static final Color NESTED_COLOR = Colors.findColor("165 42 42");
  /** Foreground colour of remark nodes and edges. */
  public static final Color REMARK_FOREGROUND = Colors.findColor("255 140 0");
  /** Background colour of remark nodes and edges. */
  public static final Color REMARK_BACKGROUND = Colors.findColor("255 255 180");

  /** Background colour of (normal) open states. */
  public static final Color OPEN_BACKGROUND = Color.GRAY.brighter();
  /** Background colour of final states. */
  public static final Color FINAL_BACKGROUND = Colors.findColor("0 200 0");
  /** Foreground colour of result states. */
  public static final Color RESULT_FOREGROUND = JAttr.STATE_BACKGROUND;
  /** Background colour of result states. */
  public static final Color RESULT_BACKGROUND = Colors.findColor("92 125 23");
  /** Background colour of error states. */
  public static final Color ERROR_BACKGROUND = Color.RED;
  /** Foreground colour of the start state. */
  public static final Color START_FOREGROUND = JAttr.STATE_BACKGROUND;
  /** Background colour of the start state. */
  public static final Color START_BACKGROUND = Color.BLACK;
  /** Background colour of the start state while it is still open. */
  public static final Color START_OPEN_BACKGROUND = Color.GRAY.darker();
  /** Foreground colour for active nodes and edges. */
  public static final Color ACTIVE_COLOR = Color.BLUE;
  /** Foreground colour for the active start node. */
  public static final Color ACTIVE_START_COLOR = Colors.findColor("40 200 255");
  /** Foreground colour for an active final node. */
  public static final Color ACTIVE_FINAL_COLOR = Colors.findColor("30 100 200");
  /** Colour used for transient states. */
  public static final Color RECIPE_COLOR = Colors.findColor("165 42 42");
  /** Colour used for transient active states. */
  public static final Color ACTIVE_RECIPE_COLOR = Colors.findColor("165 42 149");

  /** Background colour used for selected items in focused lists. */
  public static final Color FOCUS_BACKGROUND = Color.DARK_GRAY;
  /** Text colour used for selected items in focused lists. */
  public static final Color FOCUS_FOREGROUND = Color.WHITE;
  /** Background colour used for selected items in non-focused lists. */
  public static final Color SELECT_BACKGROUND = Color.LIGHT_GRAY;
  /** Text colour used for selected items in non-focused lists. */
  public static final Color SELECT_FOREGROUND = Color.BLACK;
  /** Background colour used for non-selected items in lists. */
  public static final Color NORMAL_BACKGROUND = Color.WHITE;
  /** Text colour used for non-selected items in lists. */
  public static final Color NORMAL_FOREGROUND = Color.BLACK;
  /** Text display colours to be used in normal display mode. */
  public static final Values.ColorSet NORMAL_COLORS = new Values.ColorSet();

  static {
    NORMAL_COLORS.putColors(FOCUSED, FOCUS_FOREGROUND, FOCUS_BACKGROUND);
    NORMAL_COLORS.putColors(SELECTED, SELECT_FOREGROUND, SELECT_BACKGROUND);
    NORMAL_COLORS.putColors(NONE, NORMAL_FOREGROUND, NORMAL_BACKGROUND);
  }

  /** Colour used for indicating errors in graphs. */
  public static final Color ERROR_COLOR = new Color(255, 50, 0, 40);
  /** Background colour used for focused error items in lists. */
  public static final Color ERROR_FOCUS_BACKGROUND = Color.RED.darker().darker();
  /** Text colour used for focused error items in lists. */
  public static final Color ERROR_FOCUS_FOREGROUND = Color.WHITE;
  /** Background colour used for selected, non-focused error items in lists. */
  public static final Color ERROR_SELECT_BACKGROUND = ERROR_COLOR;
  /** Text colour used for selected, non-focused error items in lists. */
  public static final Color ERROR_SELECT_FOREGROUND = Color.RED;
  /** Background colour used for non-selected, non-focused error items in lists. */
  public static final Color ERROR_NORMAL_BACKGROUND = Color.WHITE;
  /** Text colour used for non-selected, non-focused error items in lists. */
  public static final Color ERROR_NORMAL_FOREGROUND = Color.RED;
  /** Text display colours to be used in error mode. */
  public static final Values.ColorSet ERROR_COLORS = new Values.ColorSet();

  static {
    ERROR_COLORS.putColors(FOCUSED, ERROR_FOCUS_FOREGROUND, ERROR_FOCUS_BACKGROUND);
    ERROR_COLORS.putColors(SELECTED, ERROR_SELECT_FOREGROUND, ERROR_SELECT_BACKGROUND);
    ERROR_COLORS.putColors(NONE, ERROR_NORMAL_FOREGROUND, ERROR_NORMAL_BACKGROUND);
  }

  /** Text display colours to be used for transient states. */
  public static final Values.ColorSet RECIPE_COLORS = new Values.ColorSet();

  static {
    RECIPE_COLORS.putColors(FOCUSED, Color.WHITE, RECIPE_COLOR.darker());
    RECIPE_COLORS.putColors(SELECTED, RECIPE_COLOR.darker(), SELECT_BACKGROUND);
    RECIPE_COLORS.putColors(NONE, RECIPE_COLOR, NORMAL_BACKGROUND);
  }

  /** Colour of forbidden property labels. */
  public static final Color FORBIDDEN_COLOR = ERROR_COLOR;
  /** Colour of invariant property labels. */
  public static final Color INVARIANT_COLOR = CREATOR_FOREGROUND;

  /** Line style that always makes right edges. */
  public static final int STYLE_MANHATTAN = 14;

  /** Cell selection modes in trees or lists. */
  public static enum Mode {
    /** Focused selection. */
    FOCUSED,
    /** Normal selection. */
    SELECTED,
    /** No selection. */
    NONE;

    /** Converts a pair of boolean values into a selection mode. */
    public static Mode toMode(boolean selected, boolean focused) {
      if (focused) {
        return Mode.FOCUSED;
      } else if (selected) {
        return Mode.SELECTED;
      } else {
        return Mode.NONE;
      }
    }
  }

  /** Set of colours per selection mode. */
  public static class ColorSet extends DefaultFixable {
    /** Adds the foreground and background colours for a given selection mode. */
    public void putColors(Mode mode, Color foreground, Color background) {
      testFixed(false);
      Color oldFore = this.foreColors.put(mode, foreground);
      assert oldFore == null;
      Color oldBack = this.backColors.put(mode, background);
      assert oldBack == null;
      if (this.foreColors.size() == Mode.values().length) {
        setFixed();
      }
    }

    /**
     * Returns the foreground colour for the mode indicated by the parameters.
     *
     * @param selected if {@code true}, use selection mode
     * @param focused if {@code true}, use focused mode
     * @return the colour for the relevant mode
     */
    public Color getForeground(boolean selected, boolean focused) {
      return getColor(this.foreColors, selected, focused);
    }

    /**
     * Returns the foreground colour for the given selection mode
     *
     * @return the colour for the relevant mode
     */
    public Color getForeground(Mode mode) {
      return this.foreColors.get(mode);
    }

    /**
     * Returns the background colour for the mode indicated by the parameters.
     *
     * @param selected if {@code true}, use selection mode
     * @param focused if {@code true}, use focused mode
     * @return the colour for the relevant mode
     */
    public Color getBackground(boolean selected, boolean focused) {
      return getColor(this.backColors, selected, focused);
    }

    /**
     * Returns the background colour for the given selection mode
     *
     * @return the colour for the relevant mode
     */
    public Color getBackground(Mode mode) {
      return this.backColors.get(mode);
    }

    private Color getColor(Map<Mode, Color> colors, boolean selected, boolean focused) {
      return colors.get(Mode.toMode(selected, focused));
    }

    private final Map<Mode, Color> foreColors = new EnumMap<Mode, Color>(Mode.class);
    private final Map<Mode, Color> backColors = new EnumMap<Mode, Color>(Mode.class);
  }
}
Ejemplo n.º 11
0
/**
 * OSGI Shell command GUI. GUI access to the Apache Felix Shell service.
 *
 * @url http://felix.apache.org/site/apache-felix-shell.html
 * @author Nicolas Fortin
 */
public class PluginShell extends JPanel implements DockingPanel {
  private static final Logger LOGGER = Logger.getLogger("gui." + PluginShell.class);
  private static final String SHELL_SERVICE_REFERENCE = "org.apache.felix.shell.ShellService";
  private DockingPanelParameters parameters = new DockingPanelParameters();
  private static final I18n I18N = I18nFactory.getI18n(PluginShell.class);
  private final BundleContext hostBundle;
  private JTextField commandField = new JTextField();
  private JTextPane outputField = new JTextPane();
  private TextDocumentOutputStream info = new TextDocumentOutputStream(outputField, Color.BLACK);
  private TextDocumentOutputStream error =
      new TextDocumentOutputStream(outputField, Color.RED.darker());

  public PluginShell(final BundleContext hostBundle) {
    super(new BorderLayout());
    this.hostBundle = hostBundle;
    parameters.setName("plugin-shell");
    parameters.setTitle(I18N.tr("Plugin Shell"));
    parameters.setTitleIcon(new ImageIcon(PluginShell.class.getResource("panel_icon.png")));
    outputField.setEditable(false);
    outputField.setText(I18N.tr("Plugin shell, type \"help\" for command list.\n"));
    // Initialising components
    // The shell is composed by a logging part and a command line part
    add(new JScrollPane(outputField), BorderLayout.CENTER);
    add(commandField, BorderLayout.SOUTH);
    commandField.addActionListener(
        EventHandler.create(ActionListener.class, this, "onValidateCommand"));
  }

  /** User type enter on command input */
  public void onValidateCommand() {
    final String command = commandField.getText();
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            executeCommand(command);
          }
        });
    commandField.setText("");
  }

  private void executeCommand(String command) {
    // Get shell service.
    ServiceReference ref = hostBundle.getServiceReference(SHELL_SERVICE_REFERENCE);
    if (ref == null) {
      LOGGER.error(I18N.tr("No shell service is available."));
      return;
    }
    ShellService shell = (ShellService) hostBundle.getService(ref);
    try {
      // Print the command line in the output window.
      try {
        outputField
            .getDocument()
            .insertString(outputField.getDocument().getLength(), "osgi> " + command + "\n", null);
      } catch (BadLocationException ex) {
        LOGGER.debug(ex.getLocalizedMessage(), ex);
        // ignore
      }

      try {
        shell.executeCommand(command, new PrintStream(info), new PrintStream(error));
      } catch (Exception ex) {
        LOGGER.error(ex.getLocalizedMessage(), ex);
      } finally {
        try {
          // Send messages to the window
          info.flush();
          error.flush();
          outputField.setCaretPosition(outputField.getDocument().getLength());
        } catch (IOException ex) {
          LOGGER.error(ex.getLocalizedMessage(), ex);
        }
      }
    } finally {
      hostBundle.ungetService(ref);
    }
  }

  @Override
  public DockingPanelParameters getDockingParameters() {
    return parameters;
  }

  @Override
  public JComponent getComponent() {
    return this;
  }

  private class TextDocumentOutputStream extends OutputStream {

    private JTextComponent textComponent;
    private ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    // Current text Attribute for insertion, change whith style update
    private AttributeSet aset;

    public TextDocumentOutputStream(JTextComponent textComponent, Color textColor) {
      this.textComponent = textComponent;
      changeAttribute(textColor);
    }

    @Override
    public void write(int i) throws IOException {
      buffer.write(i);
    }

    @Override
    public void flush() throws IOException {
      super.flush();
      // Fetch lines in the byte array
      String messages = buffer.toString();
      if (!messages.isEmpty()) {
        Document doc = textComponent.getDocument();
        try {
          doc.insertString(doc.getLength(), messages, aset);
        } catch (BadLocationException ex) {
          LOGGER.error(I18N.tr("Cannot show the log message"), ex);
        }
      }
      buffer.reset();
    }

    private void changeAttribute(Color color) {
      StyleContext sc = StyleContext.getDefaultStyleContext();
      aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
    }
  }
}
Ejemplo n.º 12
0
  /*Place the labels on top */
  private void placeLabels() {
    /*Place label On Rent */
    GLabel onRentLabel = new GLabel("ON RENT");
    onRentLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    onRentLabel.setColor(FONTCOLOR);
    add(onRentLabel, RENTX + RENTWIDTH / 2 - onRentLabel.getWidth() / 2, RENTY - EQUIPHEIGHT);

    /*Place label Available */
    GLabel availForRentLabel = new GLabel("AVAILABLE FOR RENT");
    availForRentLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    availForRentLabel.setColor(FONTCOLOR);
    add(
        availForRentLabel,
        AVAILX + AVAILWIDTH / 2 - availForRentLabel.getWidth() / 2,
        AVAILY - EQUIPHEIGHT);

    /*Place label Shop */
    GLabel shopLabel = new GLabel("SHOP");
    shopLabel.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    shopLabel.setColor(FONTCOLOR);
    add(shopLabel, SHOPX + SHOPWIDTH / 2 - shopLabel.getWidth() / 2, SHOPY - EQUIPHEIGHT * 14);

    /*Place the lost sales label */
    lostSalesLabel1 = new GLabel("Lost Sales HR = " + lostSales.get(0));
    lostSalesLabel2 = new GLabel("Lost Sales MR = " + lostSales.get(1));
    lostSalesLabel3 = new GLabel("Lost Sales LR = " + lostSales.get(2));
    lostSalesLabel1.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    lostSalesLabel2.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    lostSalesLabel3.setFont(new Font("Serif", Font.BOLD, BIGFONTSIZE));
    lostSalesLabel1.setColor(FONTCOLOR);
    lostSalesLabel2.setColor(FONTCOLOR);
    lostSalesLabel3.setColor(FONTCOLOR);
    add(lostSalesLabel1, START_X + 4 * EQUIPWIDTH, 4 * EQUIPHEIGHT);
    add(
        lostSalesLabel2,
        START_X + 4 * EQUIPWIDTH,
        4 * EQUIPHEIGHT + lostSalesLabel1.getHeight() * 1.5);
    add(
        lostSalesLabel3,
        START_X + 4 * EQUIPWIDTH,
        4 * EQUIPHEIGHT + lostSalesLabel2.getHeight() * 3);

    /*Place the days elapsed label */
    daysElapsed = 0;
    daysElapsedLabel = new GLabel("DAY" + daysElapsed);
    daysElapsedLabel.setFont(new Font("Serif", Font.BOLD, 24));
    daysElapsedLabel.setColor(Color.red.darker());
    add(daysElapsedLabel, APPLICATION_WIDTH / 2, START_Y / 2);

    /*Place the sales Label */
    sales = 0;
    salesLabel = new GLabel("SALES: $" + sales);
    salesLabel.setFont(new Font("Serif", Font.BOLD, 24));
    salesLabel.setColor(Color.GREEN.darker());
    add(salesLabel, APPLICATION_WIDTH / 2, daysElapsedLabel.getY() + daysElapsedLabel.getY());

    /*Place the capitalInvested Label */
    capitalInvested = 0;
    capitalLabel = new GLabel("Capital Invested: $" + capitalInvested);
    capitalLabel.setFont(new Font("Serif", Font.BOLD, 18));
    capitalLabel.setColor(Color.RED.darker());
    add(
        capitalLabel,
        lostSalesLabel1.getX(),
        lostSalesLabel3.getY() + lostSalesLabel3.getHeight() * 2);
  }