コード例 #1
0
 /**
  * Return true if the position provided is on the
  *
  * @param position
  * @return
  */
 public boolean isPositionOnCancelImage(JobListItem jobItem, Point position) {
   JLabel jobCancelLabel = jobItem.getItemPanel().getJobCancelLabel();
   if (jobCancelLabel != null) {
     return jobCancelLabel.getBounds().contains(position);
   } else {
     return false;
   }
 }
コード例 #2
0
ファイル: NPCPane.java プロジェクト: CrazyPyroEagle/MEH
  @SuppressWarnings("deprecation")
  NPCPane(SpritesNPCManager mgr, int NPCIndex) {
    myIndex = NPCIndex;
    setBorder(new TitledBorder(null, "NPC", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    lblSpriteSet = new JLabel("Spriteset:");
    add(lblSpriteSet);
    lblSpriteSet.setBounds(10, 38, lblSpriteSet.getText().length() * 8, 16);
    Rectangle r = lblSpriteSet.getBounds();
    txtSpriteSet = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1));
    txtSpriteSet.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            Save(MapIO.loadedMap.mapNPCManager);
          }
        });
    add(txtSpriteSet);
    txtSpriteSet.setBounds(90, 38, 87, 16);
    // txtSpriteSet.disable();

    lblBehavior1 = new JLabel("Behavior1:");
    add(lblBehavior1);
    lblBehavior1.setBounds(10, 54, lblBehavior1.getText().length() * 8, 16);
    r = lblBehavior1.getBounds();
    txtBehavior1 = new JTextField();
    txtBehavior1.setColumns(2);
    add(txtBehavior1);
    txtBehavior1.setBounds(90, 54, 32, 16);

    lblBehavior2 = new JLabel("Behavior2:");
    add(lblBehavior2);
    lblBehavior2.setBounds(10, 70, lblBehavior2.getText().length() * 8, 16);
    r = lblBehavior2.getBounds();
    txtBehavior2 = new JTextField();
    txtBehavior2.setColumns(2);
    add(txtBehavior2);
    txtBehavior2.setBounds(90, 70, 64, 16);

    lblIsTrainer = new JLabel("Is a Trainer:");
    add(lblIsTrainer);
    lblIsTrainer.setBounds(10, 86, lblIsTrainer.getText().length() * 8, 16);
    r = lblIsTrainer.getBounds();
    chkIsTrainer = new JCheckBox();
    add(chkIsTrainer);
    chkIsTrainer.setBounds(114, 86, 32, 16);

    lblTrainerLOS = new JLabel("TrainerLOS:");
    add(lblTrainerLOS);
    lblTrainerLOS.setBounds(10, 102, lblTrainerLOS.getText().length() * 8, 16);
    r = lblTrainerLOS.getBounds();
    txtTrainerLOS = new JTextField();
    txtTrainerLOS.setColumns(3);
    add(txtTrainerLOS);
    txtTrainerLOS.setBounds(90, 102, 32, 16);

    lbliFlag = new JLabel("NPC Flag:");
    add(lbliFlag);
    lbliFlag.setBounds(10, 128, 88, 16);

    txtiFlag = new JTextField();
    txtiFlag.setColumns(4);
    add(txtiFlag);
    txtiFlag.setText("0");
    txtiFlag.setBounds(90, 128, 32, 16);

    lblScript = new JLabel("NPC Script Pointer:");
    add(lblScript);
    lblScript.setBounds(10, 150, 88, 16);

    txtScript = new JTextField();
    txtScript.setColumns(9);
    add(txtScript);
    txtScript.setText("0");
    txtScript.setBounds(90, 150, 32, 16);

    JButton btnSave = new JButton("Save");
    btnSave.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent arg0) {
            Save(MapIO.loadedMap.mapNPCManager);
          }
        });
    add(btnSave);
    btnSave.setBounds(55, 163, 89, 23);
    Load(mgr, NPCIndex);
  }
コード例 #3
0
ファイル: FlyGame.java プロジェクト: chandl34/public
 public void sendCursorLocation(AnimatedLabel label) {
   if (label instanceof Projectile)
     ((Projectile) label).sendCursorLocation(gameCursorLabel.getBounds());
 }
コード例 #4
0
  public static boolean Download(
      Settings MySettings,
      String scriptPath,
      String ProjectPath,
      String SandboxPath,
      FPGAReport MyReporter) {
    VendorSoftware alteraVendor = Settings.vendors.get(FPGAClass.VendorAltera);
    boolean SofFileExists =
        new File(SandboxPath + ToplevelHDLGeneratorFactory.FPGAToplevelName + ".sof").exists();
    GridBagConstraints gbc = new GridBagConstraints();
    JFrame panel = new JFrame("Altera Downloading");
    panel.setResizable(false);
    panel.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    GridBagLayout thisLayout = new GridBagLayout();
    panel.setLayout(thisLayout);
    // PointerInfo mouseloc = MouseInfo.getPointerInfo();
    // Point mlocation = mouseloc.getLocation();
    // panel.setLocation(mlocation.x, mlocation.y);
    JLabel LocText =
        new JLabel("Generating FPGA files and performing download; this may take a while");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(LocText, gbc);
    JProgressBar progres = new JProgressBar(0, 5);
    progres.setValue(1);
    progres.setStringPainted(true);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(progres, gbc);
    panel.pack();
    panel.setLocation(Projects.getCenteredLoc(panel.getWidth(), panel.getHeight() * 4));
    panel.setVisible(true);
    Rectangle labelRect = LocText.getBounds();
    labelRect.x = 0;
    labelRect.y = 0;
    LocText.paintImmediately(labelRect);
    List<String> command = new ArrayList<String>();
    if (!SofFileExists) {
      try {
        LocText.setText("Creating Project");
        labelRect = LocText.getBounds();
        labelRect.x = 0;
        labelRect.y = 0;
        LocText.paintImmediately(labelRect);
        command.add(alteraVendor.getBinaryPath(0));
        command.add("-t");
        command.add(scriptPath.replace(ProjectPath, ".." + File.separator) + "AlteraDownload.tcl");
        ProcessBuilder Altera1 = new ProcessBuilder(command);
        Altera1.directory(new File(SandboxPath));
        final Process CreateProject = Altera1.start();
        InputStream is = CreateProject.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        MyReporter.ClsScr();
        while ((line = br.readLine()) != null) {
          MyReporter.print(line);
        }
        CreateProject.waitFor();
        if (CreateProject.exitValue() != 0) {
          MyReporter.AddFatalError("Failed to Create a Quartus Project, cannot download");
          panel.dispose();
          return false;
        }
      } catch (IOException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      } catch (InterruptedException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      }
    }
    progres.setValue(2);
    Rectangle ProgRect = progres.getBounds();
    ProgRect.x = 0;
    ProgRect.y = 0;
    progres.paintImmediately(ProgRect);
    command.clear();
    if (!SofFileExists) {
      try {
        LocText.setText("Optimize Project");
        labelRect = LocText.getBounds();
        labelRect.x = 0;
        labelRect.y = 0;
        LocText.paintImmediately(labelRect);
        command.add(alteraVendor.getBinaryPath(2));
        command.add(ToplevelHDLGeneratorFactory.FPGAToplevelName);
        command.add("--optimize=area");
        ProcessBuilder Altera1 = new ProcessBuilder(command);
        Altera1.directory(new File(SandboxPath));
        final Process CreateProject = Altera1.start();
        InputStream is = CreateProject.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        MyReporter.ClsScr();
        while ((line = br.readLine()) != null) {
          MyReporter.print(line);
        }
        CreateProject.waitFor();
        if (CreateProject.exitValue() != 0) {
          MyReporter.AddFatalError("Failed to optimize (AREA) Project, cannot download");
          panel.dispose();
          return false;
        }
      } catch (IOException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      } catch (InterruptedException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      }
    }
    LocText.setText("Synthesizing and creating configuration file (this may take a while)");
    labelRect = LocText.getBounds();
    labelRect.x = 0;
    labelRect.y = 0;
    LocText.paintImmediately(labelRect);
    progres.setValue(3);
    ProgRect = progres.getBounds();
    ProgRect.x = 0;
    ProgRect.y = 0;
    progres.paintImmediately(ProgRect);
    if (!SofFileExists) {
      try {
        command.clear();
        command.add(alteraVendor.getBinaryPath(0));
        command.add("--flow");
        command.add("compile");
        command.add(ToplevelHDLGeneratorFactory.FPGAToplevelName);
        ProcessBuilder Altera1 = new ProcessBuilder(command);
        Altera1.directory(new File(SandboxPath));
        final Process CreateProject = Altera1.start();
        InputStream is = CreateProject.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        MyReporter.ClsScr();
        while ((line = br.readLine()) != null) {
          MyReporter.print(line);
        }
        CreateProject.waitFor();
        if (CreateProject.exitValue() != 0) {
          MyReporter.AddFatalError(
              "Failed to synthesize design and to create the configuration files, cannot download");
          panel.dispose();
          return false;
        }
      } catch (IOException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      } catch (InterruptedException e) {
        MyReporter.AddFatalError("Internal Error during Altera download");
        panel.dispose();
        return false;
      }
    }
    LocText.setText("Downloading");
    Object[] options = {"Yes, download", "No, abort"};
    if (JOptionPane.showOptionDialog(
            progres,
            "Verify that your board is connected and you are ready to download.",
            "Ready to download ?",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE,
            null,
            options,
            options[0])
        != JOptionPane.YES_OPTION) {
      MyReporter.AddWarning("Download aborted.");
      panel.dispose();
      return false;
    }

    labelRect = LocText.getBounds();
    labelRect.x = 0;
    labelRect.y = 0;
    LocText.paintImmediately(labelRect);
    progres.setValue(4);
    ProgRect = progres.getBounds();
    ProgRect.x = 0;
    ProgRect.y = 0;
    progres.paintImmediately(ProgRect);
    try {
      command.clear();
      command.add(alteraVendor.getBinaryPath(1));
      command.add("-c");
      command.add("usb-blaster");
      command.add("-m");
      command.add("jtag");
      command.add("-o");
      // if there is no .sof generated, try with the .pof
      if (new File(SandboxPath + ToplevelHDLGeneratorFactory.FPGAToplevelName + ".sof").exists()) {
        command.add("P;" + ToplevelHDLGeneratorFactory.FPGAToplevelName + ".sof");
      } else {
        command.add("P;" + ToplevelHDLGeneratorFactory.FPGAToplevelName + ".pof");
      }
      MyReporter.AddInfo(command.toString());
      ProcessBuilder Altera1 = new ProcessBuilder(command);
      Altera1.directory(new File(SandboxPath));
      final Process CreateProject = Altera1.start();
      InputStream is = CreateProject.getInputStream();
      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      String line;
      MyReporter.ClsScr();
      while ((line = br.readLine()) != null) {
        MyReporter.print(line);
      }
      CreateProject.waitFor();
      if (CreateProject.exitValue() != 0) {
        MyReporter.AddFatalError("Failed to Download design; did you connect the board?");
        panel.dispose();
        return false;
      }
    } catch (IOException e) {
      MyReporter.AddFatalError("Internal Error during Altera download");
      panel.dispose();
      return false;
    } catch (InterruptedException e) {
      MyReporter.AddFatalError("Internal Error during Altera download");
      panel.dispose();
      return false;
    }

    panel.dispose();
    return true;
  }
コード例 #5
0
  @Override
  public void editLabel() {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("Edit ie hyperlink");
    }
    labelEditing = true;
    _jLabelTextField =
        new JTextField(getModel().getValue()) {
          /**
           * Overrides paint
           *
           * @see javax.swing.JComponent#paint(java.awt.Graphics)
           */
          @Override
          public void paint(Graphics g) {
            super.paint(g);
            if (getModel().isCustomButton()) {
              Rectangle bounds = getBounds();
              g.setColor(getBackgroundColor());
              g.fillRect(0, 0, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  0, bounds.height - ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  bounds.width - ROUNDED_BORDER_SIZE, 0, ROUNDED_BORDER_SIZE, ROUNDED_BORDER_SIZE);
              g.fillRect(
                  bounds.width - ROUNDED_BORDER_SIZE,
                  bounds.height - ROUNDED_BORDER_SIZE,
                  ROUNDED_BORDER_SIZE,
                  ROUNDED_BORDER_SIZE);
            }
          }

          /**
           * Overrides getPreferredSize
           *
           * @see javax.swing.JComponent#getPreferredSize()
           */
          @Override
          public Dimension getPreferredSize() {
            if (getModel().isCustomButton()) {
              String s = _jLabelTextField.getText();
              if (s == null) {
                return new Dimension(30, 15);
              } else {
                return new Dimension(
                    (int)
                        (getFontMetrics(getFont()).getStringBounds(s, getGraphics()).getWidth()
                            + 32),
                    15);
              }
            } else {
              return super.getPreferredSize();
            }
          }
        };
    _jLabelTextField.setFont(_jLabel.getFont());
    _jLabelTextField.setForeground(_jLabel.getForeground());
    _jLabelTextField.setBackground(_jLabel.getBackground());
    if (getModel().isCustomButton()) {
      _jLabelTextField.setBorder(
          BorderFactory.createMatteBorder(0, 15, 1, 15, _jLabel.getBackground()));
    } else {
      _jLabelTextField.setBorder(BorderFactory.createEmptyBorder(0, 10, 1, 10));
    }
    // _jLabelTextField.setForeground(getFlexoNode().getTextColor());
    _jLabelTextField.setBounds(_jLabel.getBounds());
    _jLabelTextField.setHorizontalAlignment(SwingConstants.CENTER);
    _jLabelTextField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            finalizeEditHyperlink();
          }
        });
    _jLabelTextField.getDocument().addDocumentListener(new TriggerRepaintDocumentListener(this));
    _jLabelTextField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent arg0) {
            finalizeEditHyperlink();
          }
        });
    remove(_jLabel);
    add(_jLabelTextField);
    _jLabelTextField.requestFocusInWindow();
    _jLabelTextField.selectAll();
    _jLabelTextField.revalidate();
    _jLabelTextField.repaint();
    revalidate();
    repaint();
  }