コード例 #1
0
 public int getHorizontalDivider() {
   int location =
       horizontalSplitPane.getSize().width
           - horizontalSplitPane.getInsets().left
           - horizontalSplitPane.getDividerSize()
           - horizontalSplitPane.getRightComponent().getWidth();
   double width = indexingFrame.getWidth();
   double proportionalLocation = location / width;
   // horizontalSplitPane.setDividerLocation(proportionalLocation);
   return location;
 }
コード例 #2
0
 public int getVerticalDivider() {
   int location =
       verticalSplitPane.getSize().height
           - verticalSplitPane.getInsets().bottom
           - verticalSplitPane.getDividerSize()
           - verticalSplitPane.getBottomComponent().getHeight();
   double height = indexingFrame.getHeight();
   double proportionalLocation = location / height;
   //		verticalSplitPane.setDividerLocation(proportionalLocation);
   //		double check = verticalSplitPane.getDiv
   return location;
 }
コード例 #3
0
  public void createMenuBar(IndexingFrame frame) {

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menuBar.add(menu);

    JMenuItem downloadBatchMenuItem = new JMenuItem("Download Batch");
    downloadBatchMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (e.getSource() == downloadBatchMenuItem) {

              DownloadBatchDialog downloadBatchDialog =
                  new DownloadBatchDialog(frame, "Download Batch", batchState);
              downloadBatchDialog.setVisible(true);
            }
          }
        });

    JMenuItem logoutMenuItem = new JMenuItem("Logout");
    logoutMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (e.getSource() == logoutMenuItem) {

              batchState.setZoomLevel(component.getScale());
              batchState.setHighlightsVisible(component.getToggleHighlights());
              batchState.setImageInverted(component.getInverted());
              batchState.setDesktopLocation(indexingFrame.getLocation());
              batchState.setDesktopSize(indexingFrame.getSize());
              batchState.setVerticalSplit(indexingFrame.getVerticalDivider());
              batchState.setHorizontalSplit(indexingFrame.getHorizontalDivider());

              try {
                XStream xStream = new XStream(new DomDriver());

                OutputStream outFile;

                outFile = new BufferedOutputStream(new FileOutputStream("xstream.xml"));
                xStream.toXML(batchState, outFile);
                outFile.close();

              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

              frame.setVisible(false);
              parent.showLogin(batchState);
            }
          }
        });

    JMenuItem exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (e.getSource() == logoutMenuItem) {

              batchState.setZoomLevel(component.getScale());
              batchState.setHighlightsVisible(component.getToggleHighlights());
              batchState.setImageInverted(component.getInverted());
              batchState.setDesktopLocation(indexingFrame.getLocation());
              batchState.setDesktopSize(indexingFrame.getSize());
              batchState.setVerticalSplit(verticalSplitPane.getDividerLocation());
              batchState.setHorizontalSplit(horizontalSplitPane.getDividerLocation());

              try {
                XStream xStream = new XStream(new DomDriver());

                OutputStream outFile;

                outFile = new BufferedOutputStream(new FileOutputStream("xstream.xml"));
                xStream.toXML(batchState, outFile);
                outFile.close();

              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

              System.exit(0);
            }
          }
        });
    menu.add(downloadBatchMenuItem);
    menu.add(logoutMenuItem);
    menu.add(exitMenuItem);
    frame.setJMenuBar(menuBar);
  }