public static void main(String[] args) {
   if (args.length == 0) usageError();
   if (args[0].equals("cross")) {
     try {
       UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else if (args[0].equals("system")) {
     try {
       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else if (args[0].equals("motif")) {
     try {
       UIManager.setLookAndFeel("com.sun.java." + "swing.plaf.motif.MotifLookAndFeel");
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else usageError();
   // Note the look & feel must be set before
   // any components are created.
   run(new LookAndFeel(), 300, 300);
 }
      public void actionPerformed(ActionEvent ev) {
        try {
          // stok
          String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk;
          int hasil1 = stm.executeUpdate(query);

          // pemasukkan
          query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk;
          int hasil2 = stm.executeUpdate(query);

          // pengeluaran
          query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk;
          int hasil3 = stm.executeUpdate(query);

          // produk
          query = "DELETE FROM produk WHERE id_produk=" + idProduk;
          int hasil4 = stm.executeUpdate(query);

          if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "berhasil hapus");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
Example #3
0
  // write ncml from given dataset
  boolean writeNcml(String location) {
    boolean err = false;

    closeOpenFiles();

    try {
      String result;
      ds = openDataset(location, addCoords, null);
      if (ds == null) {
        editor.setText("Failed to open <" + location + ">");
      } else {
        result = new NcMLWriter().writeXML(ds);
        editor.setText(result);
        editor.setCaretPosition(0);
      }

    } catch (FileNotFoundException ioe) {
      editor.setText("Failed to open <" + location + ">");
      err = true;

    } catch (Exception e) {
      StringWriter sw = new StringWriter(10000);
      e.printStackTrace();
      e.printStackTrace(new PrintWriter(sw));
      editor.setText(sw.toString());
      err = true;
    }

    return !err;
  }
Example #4
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
Example #5
0
  public static void main(String args[]) {
    boolean debug = true;

    // Parse command-line arguments
    try {
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("-help")) {
          System.out.println("Usage: java Mesh <filename>");
          System.out.println("   or: java Mesh <shape> [uSize vSize]");
          System.out.println(" where <shape> is one of:");
          System.out.println(" -ellipsoid  -torus");
          System.exit(0);
        } else if (args[i].equals("-nodebug")) {
          debug = false;
        } else if (args[i].charAt(0) == '-') {
          // Primitive
          String primName = args[i].substring(1);

          int uSize = 24, vSize = 24;

          // Check for u/v
          if (args.length >= i + 3) {
            uSize = (new Integer(args[i + 1])).intValue();
            vSize = (new Integer(args[i + 2])).intValue();
            i += 2;
          }

          // Create primitive
          if (primName.equals("ellipsoid")) {
            shape = new Ellipsoid(uSize, vSize);
          } else if (primName.equals("torus")) {
            shape = new Torus(uSize, vSize);
          } else {
            throw new Exception("Unknown primitive: " + primName);
          }
        } else {
          // Filename
          shape = new PolyMesh(args[i]);
        }
      }
      if (shape == null) throw new Exception("No shape specified.");
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Error: " + e.getMessage());
      System.exit(1);
    }

    // Create main window
    try {
      Mesh m = new Mesh(debug);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
  public synchronized void paint(Graphics g) {
    if (mLastFrame == null) {
      return;
    }

    int framePosX = 0;
    int framePosY = 0;

    VideoFrameRef depthFrame = mLastFrame.getDepthFrame();
    if (depthFrame != null) {
      int width = depthFrame.getWidth();
      int height = depthFrame.getHeight();

      // make sure we have enough room
      if (mBufferedImage == null
          || mBufferedImage.getWidth() != width
          || mBufferedImage.getHeight() != height) {
        mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      }

      mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width);

      framePosX = (getWidth() - width) / 2;
      framePosY = (getHeight() - height) / 2;

      g.drawImage(mBufferedImage, framePosX, framePosY, null);
    }

    for (UserData user : mLastFrame.getUsers()) {
      if (user.getSkeleton().getState() == SkeletonState.TRACKED) {
        drawSkeleton(g, framePosX, framePosY, user);

        // spatial joint's coordinates
        //				giveMeSpatialCoordinateJoints(user);

        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

      if (user.getSkeleton().getState() == SkeletonState.TRACKED && startedTest) {
        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        // System.out.println("send");
      }
    }
  }
Example #7
0
    public void actionPerformed(ActionEvent ae) {

      if (ae.getActionCommand().equals("clear")) {
        scriptArea.setText("");
      } else if (ae.getActionCommand().equals("save")) {
        // fc.setCurrentDirectory(new File("/Users/jc/Documents/LOGO"));
        int bandera = fileChooser.showSaveDialog(myWindow);
        if (bandera == JFileChooser.APPROVE_OPTION) {
          String cadena1 = scriptArea.getText();
          String cadena2 = cadena1.replace("\r", "\n");
          System.out.println(cadena1);
          try {
            BufferedWriter script =
                new BufferedWriter(new FileWriter(fileChooser.getSelectedFile() + ".txt"));
            script.write(cadena2);
            script.close();
          } catch (Exception ex) {
            ex.printStackTrace();
          }
          File file = fileChooser.getSelectedFile();
          JOptionPane.showMessageDialog(myWindow, "File: " + file.getName() + " Saved.\n");
        }
        scriptArea.setCaretPosition(scriptArea.getDocument().getLength());
      } else if (ae.getActionCommand().equals("quit")) {
        myWindow.setVisible(false);
      } else if (ae.getActionCommand().equals("load")) {
        // String arreglo[] = new String[100];
        // int i = 0;
        // fc.setCurrentDirectory(new File("/Users/jc/Documents/LOGO"));
        int bandera = fileChooser.showOpenDialog(myWindow);
        if (bandera == JFileChooser.APPROVE_OPTION) {
          try {
            BufferedReader script =
                new BufferedReader(new FileReader(fileChooser.getSelectedFile()));
            scriptArea.read(script, null);
            script.close();
            scriptArea.requestFocus();
          } catch (Exception ex) {
            ex.printStackTrace();
          }
          File file = fileChooser.getSelectedFile();
          myWindow.setTitle(file.getName());
          JOptionPane.showMessageDialog(myWindow, file.getName() + ": File loaded.\n");
          scriptArea.setCaretPosition(scriptArea.getDocument().getLength());
        }
      } else if (ae.getActionCommand().equals("run")) {
        System.out.println("LEL");
      }
    }
 public void mouseClicked(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   int currentTabIndex = -1;
   int tabCount = tabPane.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     if (rects[i].contains(x, y)) {
       currentTabIndex = i;
       break;
     } // if contains
   } // for i
   if (currentTabIndex >= 0) {
     Rectangle tabRect = rects[currentTabIndex];
     x = x - tabRect.x;
     y = y - tabRect.y;
     if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) {
       try {
         tabbedPane.remove(currentTabIndex);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     } // if
   } // if currentTabIndex >= 0
   System.gc();
 } // mouseClicked
Example #9
0
 private Hashtable<String, String> getJarManifestAttributes(String path) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   JarInputStream jis = null;
   try {
     cp.appendln(Color.black, "Looking for " + path);
     InputStream is = getClass().getResourceAsStream(path);
     if (is == null) {
       if (!path.endsWith("/MIRC.jar")) {
         cp.appendln(Color.red, "...could not find it.");
       } else {
         cp.appendln(
             Color.black,
             "...could not find it. [OK, this is a " + programName + " installation]");
       }
       return null;
     }
     jis = new JarInputStream(is);
     Manifest manifest = jis.getManifest();
     h = getManifestAttributes(manifest);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   if (jis != null) {
     try {
       jis.close();
     } catch (Exception ignore) {
     }
   }
   return h;
 }
Example #10
0
 /** Launch the application. */
 public static void main(String[] args) {
   try {
     new ApptDialog(null, "Appointments", "user", true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public void loadMacros() {
   File f = new File(System.getProperty("user.dir"));
   String[] files = f.list();
   for (int i = 0; i < files.length; i++) {
     try {
       if (files[i].startsWith("macro_")
           && files[i].endsWith(".class")
           && files[i].indexOf('$') == -1) {
         System.out.println(files[i]);
         Class clazz = Class.forName(files[i].substring(0, files[i].length() - ".class".length()));
         Macro macro =
             (Macro)
                 clazz
                     .getConstructor(new Class[] {mudclient_Debug.class})
                     .newInstance(new Object[] {inner});
         String[] commands = macro.getCommands();
         for (int j = 0; j < commands.length; j++) {
           System.out.println("command registered:" + commands[j]);
           mudclient_Debug.macros.put(commands[j], macro);
         }
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Example #12
0
  public Chart(String title, String timeAxis, String valueAxis, TimeSeries data) {
    try {
      // Build the datasets
      dataset.addSeries(data);

      // Create the chart
      JFreeChart chart =
          ChartFactory.createTimeSeriesChart(
              title, timeAxis, valueAxis, dataset, true, true, false);

      // Setup the appearance of the chart
      chart.setBackgroundPaint(Color.white);
      XYPlot plot = chart.getXYPlot();
      plot.setBackgroundPaint(Color.lightGray);
      plot.setDomainGridlinePaint(Color.white);
      plot.setRangeGridlinePaint(Color.white);
      plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
      plot.setDomainCrosshairVisible(true);
      plot.setRangeCrosshairVisible(true);

      // Tell the chart how we would like dates to read
      DateAxis axis = (DateAxis) plot.getDomainAxis();
      axis.setDateFormatOverride(new SimpleDateFormat("EEE HH"));

      this.add(new ChartPanel(chart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void beginExecution() {
    if (cam == null) {

      int numBuffers = 2;

      env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      device = env.getDefaultScreenDevice();
      // MultiBufferTest test = new MultiBufferTest(numBuffers, device);

      try {

        GraphicsConfiguration gc = device.getDefaultConfiguration();
        mainFrame = new Frame(gc);
        mainFrame.setUndecorated(true);
        mainFrame.setIgnoreRepaint(true);
        device.setFullScreenWindow(mainFrame);
        if (device.isDisplayChangeSupported()) {
          chooseBestDisplayMode(device);
        }
        mainFrame.createBufferStrategy(numBuffers);
        bufferStrategy = mainFrame.getBufferStrategy();

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Example #14
0
 public StartPanel() {
   try {
     jbInit();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
 private void checkDialog(DlgResource dialog) {
   List<StructEntry> flatList = dialog.getFlatList();
   for (int i = 0; i < flatList.size(); i++) {
     if (flatList.get(i) instanceof StringRef) {
       StringRef ref = (StringRef) flatList.get(i);
       if (ref.getValue() >= 0 && ref.getValue() < strUsed.length) strUsed[ref.getValue()] = true;
     } else if (flatList.get(i) instanceof AbstractCode) {
       AbstractCode code = (AbstractCode) flatList.get(i);
       try {
         String compiled =
             infinity.resource.bcs.Compiler.getInstance()
                 .compileDialogCode(code.toString(), code instanceof Action);
         if (code instanceof Action) Decompiler.decompileDialogAction(compiled, true);
         else Decompiler.decompileDialogTrigger(compiled, true);
         Set<Integer> used = Decompiler.getStringRefsUsed();
         for (final Integer stringRef : used) {
           int u = stringRef.intValue();
           if (u >= 0 && u < strUsed.length) strUsed[u] = true;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
Example #16
0
  @Override
  protected void paintComponent(Graphics graphics) {
    // Fill in the background:
    Graphics2D g = (Graphics2D) graphics;
    Shape clip = g.getClip();
    g.setColor(LightZoneSkin.Colors.NeutralGray);
    g.fill(clip);

    if (preview == null) {
      PlanarImage image = currentImage.get();
      if (image == null) {
        engine.update(null, false);
      } else if (visibleRect != null && getHeight() > 1 && getWidth() > 1) {
        preview = cropScaleGrayscale(visibleRect, image);
      }
    }
    if (preview != null) {
      int dx, dy;
      AffineTransform transform = new AffineTransform();
      if (getSize().width > preview.getWidth()) dx = (getSize().width - preview.getWidth()) / 2;
      else dx = 0;
      if (getSize().height > preview.getHeight()) dy = (getSize().height - preview.getHeight()) / 2;
      else dy = 0;
      transform.setToTranslation(dx, dy);
      try {
        g.drawRenderedImage(preview, transform);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  /** Creates new form SIPHeadersParametersFrame */
  public StackPanel(ConfigurationFrame configurationFrame, ProxyLauncher proxyLauncher) {
    super();
    this.parent = configurationFrame;
    this.proxyLauncher = proxyLauncher;

    listeningPointsList = new ListeningPointsList(proxyLauncher);

    initComponents();

    // Init the components input:
    try {
      Configuration configuration = proxyLauncher.getConfiguration();
      if (configuration == null) return;
      if (configuration.stackName != null) proxyStackNameTextField.setText(configuration.stackName);
      if (configuration.stackIPAddress != null)
        proxyIPAddressTextField.setText(configuration.stackIPAddress);

      if (configuration.outboundProxy != null)
        outboundProxyTextField.setText(configuration.outboundProxy);
      if (configuration.routerPath != null) routerClassTextField.setText(configuration.routerPath);
      if (configuration == null) listeningPointsList.displayList(new Hashtable());
      else listeningPointsList.displayList(configuration.listeningPoints);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #18
0
  /**
   * Calculates location of caret and displays the suggestion popup at the location.
   *
   * @param listModel
   * @param subWord
   */
  protected void showSuggestion(DefaultListModel<CompletionCandidate> listModel, String subWord) {
    // new Exception(System.currentTimeMillis() + "").printStackTrace(System.out);
    hideSuggestion();

    if (listModel.size() == 0) {
      Messages.log("TextArea: No suggestions to show.");

    } else {
      int position = getCaretPosition();
      Point location = new Point();
      try {
        location.x = offsetToX(getCaretLine(), position - getLineStartOffset(getCaretLine()));
        location.y =
            lineToY(getCaretLine())
                + getPainter().getFontMetrics().getHeight()
                + getPainter().getFontMetrics().getDescent();
        // log("TA position: " + location);
      } catch (Exception e2) {
        e2.printStackTrace();
        return;
      }

      suggestion = new CompletionPanel(this, position, subWord, listModel, location, editor);
      requestFocusInWindow();
    }
  }
  protected boolean refreshFeatureSelection(String layerName, String id) {

    try {
      if (id == null || geopistaEditor == null) return false;
      this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      geopistaEditor.getSelectionManager().clear();
      GeopistaLayer geopistaLayer =
          (GeopistaLayer) geopistaEditor.getLayerManager().getLayer(layerName);
      Collection collection = searchByAttribute(geopistaLayer, 0, id);
      Iterator it = collection.iterator();
      if (it.hasNext()) {
        Feature feature = (Feature) it.next();
        geopistaEditor.select(geopistaLayer, feature);
      }
      geopistaEditor.zoomToSelected();
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      return true;
    } catch (Exception ex) {
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return false;
    }
  }
  protected String refreshListSelection(String layerName) {
    try {

      Collection collection = geopistaEditor.getSelection();
      if (collection.iterator().hasNext()) {
        GeopistaFeature feature = (GeopistaFeature) collection.iterator().next();
        if (feature == null) {
          logger.error("feature: " + feature);
          return null;
        }

        if (layerName != null && feature.getLayer() != null) {
          if (!layerName.equals(feature.getLayer().getName())) return null;
        }
        // String id = checkNull(feature.getAttribute(0));
        String id = checkNull(feature.getSystemId());
        logger.info("id: -" + id + "-");
        return id;
      }
    } catch (Exception ex) {

      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      logger.error("Exception: " + sw.toString());
      return null;
    }
    return null;
  }
  public void run() {
    try {

      setStatus("Gathering chunks...");
      gatherChunks();
      createCompositeCanvas();
      setStatus("Sorting chunks...");
      sortChunks();
      java.util.List<BufferedImage> batchImages = new ArrayList<BufferedImage>();
      java.util.List<Chunk> nextBatch = new ArrayList<Chunk>();
      int totalChunks = getTotalChunks();
      int chunksRendered = 0;
      while (hasChunks()) {
        getNextBatch(nextBatch);
        setStatus("Rendering... " + chunksRendered + "/" + totalChunks);
        renderChunkBatch(nextBatch, batchImages);
        chunksRendered += nextBatch.size();
        renderBatchResult(nextBatch, batchImages);
      }
      setStatus("Writing image...");
      writeAndDisplayImage();
    } catch (final Exception e) {
      e.printStackTrace();
      if (frame != null) {
        setStatus("Exception: " + e.toString());
      }
    }
  }
Example #22
0
 public ST133Setup() {
   try {
     jbInit();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public JournalFilterFrame() {
    try {
      jbInit();

      // set domain in combo box...
      ClientApplet applet =
          ((ApplicationClientFacade) MDIFrame.getInstance().getClientFacade()).getMainClass();
      ButtonCompanyAuthorizations bca = applet.getAuthorizations().getCompanyBa();
      ArrayList companiesList = bca.getCompaniesList("ACC05");
      Domain domain = new Domain("DOMAIN_ACC05");
      for (int i = 0; i < companiesList.size(); i++) {
        if (applet
            .getAuthorizations()
            .getCompanyBa()
            .isInsertEnabled("ACC05", companiesList.get(i).toString()))
          domain.addDomainPair(companiesList.get(i), companiesList.get(i).toString());
      }
      controlCompaniesCombo.setDomain(domain);
      controlCompaniesCombo.getComboBox().setSelectedIndex(0);

      setSize(400, 200);
      MDIFrame.getInstance().add(this);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void run() {
    while (true) {
      try {
        DatagramSocket ClientSoc = new DatagramSocket(ClinetPortNumber);
        String Command = "GET";

        byte Sendbuff[] = new byte[1024];
        Sendbuff = Command.getBytes();

        InetAddress ServerHost = InetAddress.getLocalHost();
        ClientSoc.send(new DatagramPacket(Sendbuff, Sendbuff.length, ServerHost, 5217));

        byte Receivebuff[] = new byte[1024];
        DatagramPacket dp = new DatagramPacket(Receivebuff, Receivebuff.length);
        ClientSoc.receive(dp);

        NewsMsg = new String(dp.getData(), 0, dp.getLength());
        System.out.println(NewsMsg);
        lblNewsHeadline.setText(NewsMsg);

        Thread.sleep(5000);
        ClientSoc.close();
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
 private static void printHelp(OptionParser parser) {
   try {
     parser.printHelpOn(System.out);
   } catch (Exception exception) {
     exception.printStackTrace();
   }
 }
Example #26
0
  public Chart(String filename) {
    try {
      // Get Stock Symbol
      this.stockSymbol = filename.substring(0, filename.indexOf('.'));

      // Create time series
      TimeSeries open = new TimeSeries("Open Price", Day.class);
      TimeSeries close = new TimeSeries("Close Price", Day.class);
      TimeSeries high = new TimeSeries("High", Day.class);
      TimeSeries low = new TimeSeries("Low", Day.class);
      TimeSeries volume = new TimeSeries("Volume", Day.class);

      BufferedReader br = new BufferedReader(new FileReader(filename));
      String key = br.readLine();
      String line = br.readLine();
      while (line != null && !line.startsWith("<!--")) {
        StringTokenizer st = new StringTokenizer(line, ",", false);
        Day day = getDay(st.nextToken());
        double openValue = Double.parseDouble(st.nextToken());
        double highValue = Double.parseDouble(st.nextToken());
        double lowValue = Double.parseDouble(st.nextToken());
        double closeValue = Double.parseDouble(st.nextToken());
        long volumeValue = Long.parseLong(st.nextToken());

        // Add this value to our series'
        open.add(day, openValue);
        close.add(day, closeValue);
        high.add(day, highValue);
        low.add(day, lowValue);

        // Read the next day
        line = br.readLine();
      }

      // Build the datasets
      dataset.addSeries(open);
      dataset.addSeries(close);
      dataset.addSeries(low);
      dataset.addSeries(high);
      datasetOpenClose.addSeries(open);
      datasetOpenClose.addSeries(close);
      datasetHighLow.addSeries(high);
      datasetHighLow.addSeries(low);

      JFreeChart summaryChart = buildChart(dataset, "Summary", true);
      JFreeChart openCloseChart = buildChart(datasetOpenClose, "Open/Close Data", false);
      JFreeChart highLowChart = buildChart(datasetHighLow, "High/Low Data", true);
      JFreeChart highLowDifChart =
          buildDifferenceChart(datasetHighLow, "High/Low Difference Chart");

      // Create this panel
      this.setLayout(new GridLayout(2, 2));
      this.add(new ChartPanel(summaryChart));
      this.add(new ChartPanel(openCloseChart));
      this.add(new ChartPanel(highLowChart));
      this.add(new ChartPanel(highLowDifChart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #27
0
 public static void main(String[] args) {
   Example4 ef = new Example4();
   try {
     final String molS = "C1C2=CC=CC=C2C3=C4CC5=CC=CC=C5C4=C6CC7=CC=CC=C7C6=C13";
     Molecule mol = MolImporter.importMol(molS);
     PolarizabilityPlugin plugin = new PolarizabilityPlugin();
     plugin.setMolecule(mol);
     plugin.run();
     ArrayList values = new ArrayList();
     java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
     nf.setMaximumFractionDigits(3);
     for (int i = 0; i < mol.getAtomCount(); i++) {
       values.add(Float.valueOf(nf.format(((Double) plugin.getResult(i)).floatValue())));
     }
     mol.hydrogenize(true);
     for (int i = 0; i < mol.getExplicitHcount(); i++) {
       values.add(new Double(0));
     }
     ef.setPlugin(plugin);
     JFrame frame = ef.createSpaceFrame(mol, values);
     frame.setTitle("Polarizability");
     java.net.URL u = ef.getClass().getResource("/chemaxon/marvin/space/gui/mspace16.gif");
     frame.setIconImage(
         Toolkit.getDefaultToolkit().createImage((java.awt.image.ImageProducer) u.getContent()));
     frame.setVisible(true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
    public void run() {
      try {
        if (myPreviousThread != null) myPreviousThread.join();
        Thread.sleep(delay);
        log("> run MouseMoveThread " + x + ", " + y);
        while (!hasFocus()) {
          Thread.sleep(1000);
        }
        int x1 = lastMouseX;
        int x2 = x;
        int y1 = lastMouseY;
        int y2 = y;
        // shrink range by 1 px on both ends
        // manually move this 1px to trip DND code
        if (x1 != x2) {
          int dx = x - lastMouseX;
          if (dx > 0) {
            x1 += 1;
            x2 -= 1;
          } else {
            x1 -= 1;
            x2 += 1;
          }
        }
        if (y1 != y2) {
          int dy = y - lastMouseY;
          if (dy > 0) {
            y1 += 1;
            y2 -= 1;
          } else {
            y1 -= 1;
            y2 += 1;
          }
        }
        robot.setAutoDelay(Math.max(duration / 100, 1));
        robot.mouseMove(x1, y1);
        int d = 100;
        for (int t = 0; t <= d; t++) {
          x1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseX, (double) x2 - lastMouseX, (double) d);
          y1 =
              (int)
                  easeInOutQuad(
                      (double) t, (double) lastMouseY, (double) y2 - lastMouseY, (double) d);
          robot.mouseMove(x1, y1);
        }
        robot.mouseMove(x, y);
        lastMouseX = x;
        lastMouseY = y;
        robot.waitForIdle();
        robot.setAutoDelay(1);
      } catch (Exception e) {
        log("Bad parameters passed to mouseMove");
        e.printStackTrace();
      }

      log("< run MouseMoveThread");
    }
Example #29
0
 /** i_square,resultの有効期間は、この関数の終了までです。 */
 protected void onUpdateHandler(NyARSquare i_square, NyARDoubleMatrix44 result) {
   try {
     NyARGLUtil.toCameraViewRH(result, 1.0, this.gltransmat);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #30
0
 /**
  * Appends a frame to the current video.
  *
  * @param image the image to append
  * @return true if image successfully appended
  */
 protected boolean append(Image image) {
   BufferedImage bi;
   if (image instanceof BufferedImage) {
     bi = (BufferedImage) image;
   } else {
     bi = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB);
     Graphics2D g = bi.createGraphics();
     g.drawImage(image, 0, 0, null);
   }
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   try {
     if (!editing) {
       videoMedia.beginEdits();
       editing = true;
     }
     ImageIO.write(bi, "png", out); // $NON-NLS-1$
     QTHandle handle = new QTHandle(out.toByteArray());
     DataRef dataRef = new DataRef(handle, kDataRefFileExtensionTag, "png"); // $NON-NLS-1$
     GraphicsImporter importer = new GraphicsImporter(dataRef);
     ImageDescription description = importer.getImageDescription();
     int duration = (int) (frameDuration * 0.6);
     videoMedia.addSample(
         handle,
         0, // data offset
         handle.getSize(),
         duration,
         description,
         1, // number of samples
         0); // key frame??
   } catch (Exception ex) {
     ex.printStackTrace();
     return false;
   }
   return true;
 }