public File takeScreenshot(WebElement element) {
    if (!WebDriverRunner.hasWebDriverStarted()) {
      log.warning("Cannot take screenshot because browser is not started");
      return null;
    }

    WebDriver webdriver = getWebDriver();
    if (!(webdriver instanceof TakesScreenshot)) {
      log.warning("Cannot take screenshot because browser does not support screenshots");
      return null;
    }

    File screen = ((TakesScreenshot) webdriver).getScreenshotAs(OutputType.FILE);

    Point p = element.getLocation();
    Dimension elementSize = element.getSize();

    try {
      BufferedImage img = ImageIO.read(screen);
      BufferedImage dest =
          img.getSubimage(p.getX(), p.getY(), elementSize.getWidth(), elementSize.getHeight());
      ImageIO.write(dest, "png", screen);
      File screenshotOfElement = new File(generateScreenshotFileName());
      FileUtils.copyFile(screen, screenshotOfElement);
      return screenshotOfElement;
    } catch (IOException e) {
      printOnce("takeScreenshotImage", e);
      return null;
    }
  }
 public void paint(Graphics g) {
   MetalBumps usedBumps;
   if (splitPane.hasFocus()) {
     usedBumps = focusBumps;
     g.setColor(primaryControlColor);
   } else {
     usedBumps = bumps;
     g.setColor(controlColor);
   }
   Rectangle clip = g.getClipBounds();
   Insets insets = getInsets();
   g.fillRect(clip.x, clip.y, clip.width, clip.height);
   Dimension size = getSize();
   size.width -= inset * 2;
   size.height -= inset * 2;
   int drawX = inset;
   int drawY = inset;
   if (insets != null) {
     size.width -= (insets.left + insets.right);
     size.height -= (insets.top + insets.bottom);
     drawX += insets.left;
     drawY += insets.top;
   }
   usedBumps.setBumpArea(size);
   usedBumps.paintIcon(this, g, drawX, drawY);
   super.paint(g);
 }
Example #3
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
  void jButtonWeights_actionPerformed(ActionEvent e) {
    NumberGeneratorDialog dlg =
        new NumberGeneratorDialog(
            (Frame) null,
            "Weights",
            "Weight of synaptic connections",
            mySynProps.getWeightsGenerator(),
            true);

    // Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dlg.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    dlg.setLocation(
        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    dlg.setVisible(true);

    jTextFieldWeights.setText(mySynProps.getWeightsGenerator().toShortString());

    // mySynProps.setWeightsGenerator(dlg.getFinalNumGen());
  }
  /*
   *  Adjust the width of the scrollpane used by the popup
   */
  protected void popupWider(BasicComboPopup popup) {
    JList list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth =
        list.getPreferredSize().width
            + 5 // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
      popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
  }
Example #6
0
 /**
  * Get the preferred size at which this Widget will look best. When a WidgetContainer lays out its
  * contents, it will attempt to make this Widget as close as possible to its preferred size.
  */
 public Dimension getPreferredSize() {
   if (prefColSize == null) calculateSizes();
   Dimension prefSize = new Dimension(0, 0);
   for (int i = 0; i < prefColSize.length; i++) prefSize.width += prefColSize[i];
   for (int i = 0; i < prefRowSize.length; i++) prefSize.height += prefRowSize[i];
   return prefSize;
 }
Example #7
0
 public boolean isInLimits(float x, float y) {
   if (x < 0) return false;
   if (y < 0) return false;
   long ux = (long) x;
   long uy = (long) y;
   return ux < dimension.getWidth() && uy < dimension.getHeight();
 }
Example #8
0
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
 @Override
 public Dimension getPreferredSize() {
   Dimension size = super.getPreferredSize();
   UIManager.LookAndFeelInfo info = LafManager.getInstance().getCurrentLookAndFeel();
   if (info != null && info.getName().contains("Windows")) size.width += 10;
   return size;
 }
    @Override
    public void layoutContainer(final Container parent) {
      final int componentCount = parent.getComponentCount();
      if (componentCount == 0) return;
      final EditorEx history = myHistoryViewer;
      final EditorEx editor = componentCount == 2 ? myConsoleEditor : null;

      if (editor == null) {
        parent.getComponent(0).setBounds(parent.getBounds());
        return;
      }

      final Dimension panelSize = parent.getSize();
      if (panelSize.getHeight() <= 0) return;
      final Dimension historySize = history.getContentSize();
      final Dimension editorSize = editor.getContentSize();
      final Dimension newEditorSize = new Dimension();

      // deal with width
      final int width = Math.max(editorSize.width, historySize.width);
      newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight();
      history.getSoftWrapModel().forceAdditionalColumnsUsage();
      editor
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
      history
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));

      // deal with height
      if (historySize.width == 0) historySize.height = 0;
      final int minHistorySize =
          historySize.height > 0
              ? 2 * history.getLineHeight() + (myShowSeparatorLine ? SEPARATOR_THICKNESS : 0)
              : 0;
      final int minEditorSize = editor.isViewer() ? 0 : editor.getLineHeight();
      final int editorPreferred =
          editor.isViewer() ? 0 : Math.max(minEditorSize, editorSize.height);
      final int historyPreferred = Math.max(minHistorySize, historySize.height);
      if (panelSize.height < minEditorSize) {
        newEditorSize.height = panelSize.height;
      } else if (panelSize.height < editorPreferred) {
        newEditorSize.height = panelSize.height - minHistorySize;
      } else if (panelSize.height < editorPreferred + historyPreferred) {
        newEditorSize.height = editorPreferred;
      } else {
        newEditorSize.height = editorPreferred == 0 ? 0 : panelSize.height - historyPreferred;
      }
      final Dimension newHistorySize =
          new Dimension(width, panelSize.height - newEditorSize.height);

      // apply
      editor
          .getComponent()
          .setBounds(0, newHistorySize.height, panelSize.width, newEditorSize.height);
      myForceScrollToEnd.compareAndSet(false, shouldScrollHistoryToEnd());
      history.getComponent().setBounds(0, 0, panelSize.width, newHistorySize.height);
    }
  private void setHeaderComponent(JComponent c) {
    boolean doRevalidate = false;
    if (myHeaderComponent != null) {
      myHeaderPanel.remove(myHeaderComponent);
      myHeaderPanel.add(myCaption, BorderLayout.NORTH);
      myHeaderComponent = null;
      doRevalidate = true;
    }

    if (c != null) {
      myHeaderPanel.remove(myCaption);
      myHeaderPanel.add(c, BorderLayout.NORTH);
      myHeaderComponent = c;

      final Dimension size = myContent.getSize();
      if (size.height < c.getPreferredSize().height * 2) {
        size.height += c.getPreferredSize().height;
        setSize(size);
      }

      doRevalidate = true;
    }

    if (doRevalidate) myContent.revalidate();
  }
  private void checkSizes() {
    Dimension vsz = scroll_pane.getViewport().getViewSize();
    Dimension csz = draw_area.getSize();
    Dimension nsz = new Dimension((int) (vsz.width * x_scale), (int) (vsz.height * y_scale));
    boolean chng = false;

    if (nsz.width > csz.width) {
      if (vsz.width >= csz.width) {
        csz.width = vsz.width;
        chng = true;
        x_scale = 1;
      }
    } else if (nsz.width < csz.width) {
      if (x_scale == 1) {
        csz.width = vsz.width;
        chng = true;
      }
    }

    if (nsz.height > csz.height) {
      if (vsz.height >= csz.height) {
        csz.height = vsz.height;
        chng = true;
        y_scale = 1;
      }
    } else if (nsz.height < csz.height) {
      if (y_scale == 1) {
        csz.height = vsz.height;
        chng = true;
      }
    }

    if (chng) draw_area.setSize(csz);
  }
Example #13
0
 /**
  * Returns the preferred size of the viewport for a view component. For example the preferredSize
  * of a JList component is the size required to acommodate all of the cells in its list however
  * the value of preferredScrollableViewportSize is the size required for
  * JList.getVisibleRowCount() rows. A component without any properties that would effect the
  * viewport size should just return getPreferredSize() here.
  *
  * @return The preferredSize of a JViewport whose view is this Scrollable.
  * @see JViewport#getPreferredSize
  */
 public Dimension getPreferredScrollableViewportSize() {
   Dimension size = getPreferredSize();
   Dimension retval = new Dimension();
   retval.width = size.width > 600 ? 600 : size.width;
   retval.height = size.height > 400 ? 400 : size.height;
   return retval;
 }
Example #14
0
 /**
  * Returns whether the input Object is equivalent to this Dimension. <code>true</code> if the
  * Object is a Dimension and its width and height are equal to this Dimension's width and height,
  * <code>false</code> otherwise.
  *
  * @param o the Object being tested for equality
  * @return <code>true</code> if the given object is equal to this dimension
  * @since 2.0
  */
 public boolean equals(Object o) {
   if (o instanceof Dimension) {
     Dimension d = (Dimension) o;
     return (d.width() == width && d.height() == height);
   }
   return false;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#getPreferredSize(javax
   * .swing.JComponent)
   */
  @Override
  public Dimension getPreferredSize(JComponent c) {
    AbstractCommandButton button = (AbstractCommandButton) c;
    SubstanceButtonShaper shaper = SubstanceCoreUtilities.getButtonShaper(button);

    Dimension superPref = super.getPreferredSize(button);
    if (superPref == null) return null;

    if (shaper == null) return superPref;

    // fix for issue 35 on Flamingo - do not enforce
    // min size on buttons in the ribbon
    // Additional fix - buttons with popup action should
    // not have min size enforced as well
    // Additional fix - buttons in popup menus and breadcrumb bars should
    // not have min size enforced
    if ((button.getDisplayState() == CommandButtonDisplayState.MEDIUM)
        && (SwingUtilities.getAncestorOfClass(AbstractRibbonBand.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JBreadcrumbBar.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JCommandPopupMenu.class, button) == null)) {
      JButton dummy = new JButton(button.getText(), button.getIcon());
      Dimension result = shaper.getPreferredSize(dummy, superPref);
      if (FlamingoUtilities.hasPopupAction(button)) {
        result.width = superPref.width;
      }
      return result;
    }
    return superPref;
  }
  @Nullable
  private static Value createScaledBitmap(
      @NotNull EvaluationContextImpl context,
      @NotNull ObjectReference bitmap,
      @NotNull Dimension currentDimensions)
      throws EvaluateException {
    DebugProcessImpl debugProcess = context.getDebugProcess();
    Method createScaledBitmapMethod =
        DebuggerUtils.findMethod(
            bitmap.referenceType(),
            "createScaledBitmap",
            "(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;");
    if (createScaledBitmapMethod == null) {
      return null;
    }

    double s =
        Math.max(currentDimensions.getHeight(), currentDimensions.getWidth()) / MAX_DIMENSION;

    VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy();
    Value dstWidth =
        DebuggerUtilsEx.createValue(vm, "int", (int) (currentDimensions.getWidth() / s));
    Value dstHeight =
        DebuggerUtilsEx.createValue(vm, "int", (int) (currentDimensions.getHeight() / s));
    Value filter = DebuggerUtilsEx.createValue(vm, "boolean", Boolean.FALSE);
    return debugProcess.invokeMethod(
        context,
        bitmap,
        createScaledBitmapMethod,
        Arrays.asList(bitmap, dstWidth, dstHeight, filter));
  }
Example #17
0
 /**
  * Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays
  * out its contents, it will attempt never to make this Widget smaller than its minimum size.
  */
 public Dimension getMinimumSize() {
   if (minColSize == null) calculateSizes();
   Dimension minSize = new Dimension(0, 0);
   for (int i = 0; i < minColSize.length; i++) minSize.width += minColSize[i];
   for (int i = 0; i < minRowSize.length; i++) minSize.height += minRowSize[i];
   return minSize;
 }
 public void processCellResized(
     RadContainer container, final boolean isRow, final int cell, final int newSize) {
   int cellCount = isRow ? container.getGridRowCount() : container.getGridColumnCount();
   if (container.getParent().isXY() && cell == cellCount - 1) {
     processRootContainerResize(container, isRow, newSize);
   } else {
     for (RadComponent component : container.getComponents()) {
       GridConstraints c = component.getConstraints();
       if (c.getCell(isRow) == cell && c.getSpan(isRow) == 1) {
         Dimension preferredSize = new Dimension(c.myPreferredSize);
         if (isRow) {
           preferredSize.height = newSize;
           if (preferredSize.width == -1) {
             preferredSize.width = component.getDelegee().getPreferredSize().width;
           }
         } else {
           preferredSize.width = newSize;
           if (preferredSize.height == -1) {
             preferredSize.height = component.getDelegee().getPreferredSize().height;
           }
         }
         PreferredSizeProperty.getInstance(container.getProject())
             .setValueEx(component, preferredSize);
       }
     }
   }
 }
Example #19
0
  private void show(int _current) {
    OpenDefinitionsDocument doc = _docs.get(_current);

    String text = getTextFor(doc);

    _label.setText(_displayManager.getName(doc));
    _label.setIcon(_displayManager.getIcon(doc));

    if (text.length() > 0) {
      // as wide as the text area wants, but only 200px high
      _textpane.setText(text);
      _scroller.setPreferredSize(_textpane.getPreferredScrollableViewportSize());
      if (_scroller.getPreferredSize().getHeight() > 200)
        _scroller.setPreferredSize(
            new Dimension((int) _scroller.getPreferredSize().getWidth(), 200));

      _scroller.setVisible(_showSource);
    } else _scroller.setVisible(false);

    Dimension d = _label.getMinimumSize();
    d.setSize(d.getWidth() + _padding * 2, d.getHeight() + _padding * 2);
    _label.setPreferredSize(d);
    _label.setHorizontalAlignment(SwingConstants.CENTER);
    _label.setVerticalAlignment(SwingConstants.CENTER);
    pack();
    centerH();
  }
Example #20
0
  public ActionBar(View view, boolean temp) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    this.view = view;
    this.temp = temp;

    add(Box.createHorizontalStrut(2));

    JLabel label = new JLabel(jEdit.getProperty("view.action.prompt"));
    add(label);
    add(Box.createHorizontalStrut(12));
    add(action = new ActionTextField());
    action.setEnterAddsToHistory(false);
    Dimension max = action.getPreferredSize();
    max.width = Integer.MAX_VALUE;
    action.setMaximumSize(max);
    action.addActionListener(new ActionHandler());
    action.getDocument().addDocumentListener(new DocumentHandler());

    if (temp) {
      close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif"));
      close.addActionListener(new ActionHandler());
      close.setToolTipText(jEdit.getProperty("view.action.close-tooltip"));
      add(close);
    }

    this.temp = temp;
  }
Example #21
0
  /** Paint it. */
  public void paint(Graphics g) {
    Dimension d = getSize();
    if (!inited || buff == null || d.width != buffSize.width || d.height != buffSize.height) {
      buffSize.width = d.width;
      buffSize.height = d.height;
      buff = createImage(d.width + 4, d.height + 4);
      if (buff == null) return;
      buffG = buff.getGraphics();
      inited = true;
    }

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width, prefSize.height);
    PressedRect(buffG, 0, 0, prefSize.width - 2, prefSize.height - 2);

    buffG.setColor(Color.lightGray);
    buffG.fillRect(0, 0, prefSize.width + 2, prefSize.height + 2);
    if (!gameover) if ((gameover = is_game_over())) end_game();
    for (int i = 0; i < rows; i++) {
      for (int j = 0; j < cols; j++) {
        drawBlock(buffG, i, j, status(i, j));
      }
    }
    // PressedRect(buffG,0,0,prefSize.width + 2,prefSize.height + 2);
    if (buff != null) g.drawImage(buff, 0, 0, null);
  }
  public void paint(Graphics g) {
    // Only create the image at the beginning -
    if ((img == null) || (prefsize.width != size().width) || (prefsize.height != size().height)) {
      prefsize.width = size().width;
      prefsize.height = size().height;

      scale = findScale();

      //      System.out.println("New scale = " + scale);
      img = createImage(size().width, size().height);
      ig = img.getGraphics();

      redrawneeded = true;
    }

    if (redrawneeded == true) {
      drawBackground(ig, Color.black);
      drawScene(ig);
      if (drawAxes == true) {
        drawAxes(ig);
      }
      redrawneeded = false;
    } else {
      ig = img.getGraphics();
    }

    g.drawImage(img, 0, 0, this);
  }
  private void calculateWrapSize(Rectangle bounds) {
    if (myWrapSize.width == -1 || myWrapSize.height == -1) {
      try {
        Object viewObject = myComponent.getViewInfo().getViewObject();
        Class<?> viewClass = viewObject.getClass();

        viewClass.getMethod("forceLayout").invoke(viewObject);
        viewClass
            .getMethod("measure", int.class, int.class)
            .invoke(viewObject, WRAP_CONTENT, WRAP_CONTENT);

        if (myWrapSize.width == -1) {
          myWrapSize.width = (Integer) viewClass.getMethod("getMeasuredWidth").invoke(viewObject);
        }
        if (myWrapSize.height == -1) {
          myWrapSize.height = (Integer) viewClass.getMethod("getMeasuredHeight").invoke(viewObject);
        }
      } catch (Throwable e) {
        if (myWrapSize.width == -1) {
          myWrapSize.width = bounds.width;
        }
        if (myWrapSize.height == -1) {
          myWrapSize.height = bounds.height;
        }
      }
    }
  }
Example #24
0
  public VDialog() {
    setSize(250, 250);
    setUndecorated(true); // remove the window bar
    // the following lines of code calculate a random coordinate to position the dialog
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = (int) screenSize.getWidth();
    int height = (int) screenSize.getHeight();
    Random rn = new Random();
    int xPos = rn.nextInt(width - 250);
    int yPos = rn.nextInt(height - 250);
    this.setLocation(xPos, yPos);

    // set transparent background color
    Color c = new Color(0, 0, 0, 0);
    setBackground(c);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addKeyListener(new MKeyListener());
    // put the image of the cow
    try {
      this.add(
          new JLabel(
              new ImageIcon(
                  ImageIO.read(getClass().getResourceAsStream("/resources/cow_rszd.png")))));
    } catch (IOException e) {
      e.printStackTrace();
    }
    pack();
    setVisible(true);
  }
  /*
   *  This method is called every time:
   *  - to make sure the viewport is returned to its default position
   *  - to remove the horizontal scrollbar when it is not wanted
   */
  private void checkHorizontalScrollBar(BasicComboPopup popup) {
    //  Reset the viewport to the left

    JViewport viewport = scrollPane.getViewport();
    Point p = viewport.getViewPosition();
    p.x = 0;
    viewport.setViewPosition(p);

    //  Remove the scrollbar so it is never painted

    if (!scrollBarRequired) {
      scrollPane.setHorizontalScrollBar(null);
      return;
    }

    //	Make sure a horizontal scrollbar exists in the scrollpane

    JScrollBar horizontal = scrollPane.getHorizontalScrollBar();

    if (horizontal == null) {
      horizontal = new JScrollBar(JScrollBar.HORIZONTAL);
      scrollPane.setHorizontalScrollBar(horizontal);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }

    //	Potentially increase height of scroll pane to display the scrollbar

    if (horizontalScrollBarWillBeVisible(popup, scrollPane)) {
      Dimension scrollPaneSize = scrollPane.getPreferredSize();
      scrollPaneSize.height += horizontal.getPreferredSize().height;
      scrollPane.setPreferredSize(scrollPaneSize);
      scrollPane.setMaximumSize(scrollPaneSize);
      scrollPane.revalidate();
    }
  }
Example #26
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
  /**
   * Calculates the preferred size dimensions for the specified panel given the components in the
   * specified parent container.
   *
   * @param target The component to be laid out.
   * @return A size deemed suitable for laying out the container.
   * @see #minimumLayoutSize
   */
  public Dimension preferredLayoutSize(Container target) {
    int count;
    Component component;
    Dimension dimension;
    Insets insets;
    Dimension ret;

    synchronized (target.getTreeLock()) {
      // get the the total height and maximum width component
      ret = new Dimension(0, 0);
      count = target.getComponentCount();
      for (int i = 0; i < count; i++) {
        component = target.getComponent(i);
        if (component.isVisible()) {
          dimension = component.getPreferredSize();
          ret.width = Math.max(ret.width, dimension.width);
          ret.height += dimension.height;
        }
      }
      insets = target.getInsets();
      ret.width += insets.left + insets.right;
      ret.height += insets.top + insets.bottom;
    }

    return (ret);
  }
Example #28
0
    /**
     * Calculates the maximum size dimensions for the specified panal given the components in the
     * specified parent container.
     */
    public Dimension maximumLayoutSize(Container target) {
      synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int size = actions.size();
        if ((grip != null) && grip.isVisible()) {
          Dimension d = grip.getPreferredSize();
          dim.width += d.width;
          dim.width += hgap;
        }
        Component last = null;
        for (int i = 0; i < size; i++) {
          Component comp = (Component) actions.elementAt(i);
          if (comp.isVisible()) {
            Dimension d = comp.getPreferredSize();
            dim.width += d.width;
            dim.height = Math.max(dim.height, d.height);
            dim.width += hgap;
            last = comp;
          }
        }
        if (last != null) {
          Dimension prefSize = last.getPreferredSize();
          Dimension maxSize = last.getMaximumSize();
          if (prefSize != maxSize) {
            dim.width = dim.width - prefSize.width + maxSize.width;
            dim.height = Math.max(dim.height, maxSize.height);
          }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

        return dim;
      }
    }
Example #29
0
  public Dimension requestResize(
      final Dimension newSize,
      final RequestOrigin origin,
      int cursorY,
      JediTerminal.ResizeHandler resizeHandler) {
    if (!newSize.equals(myTermSize)) {
      myTerminalTextBuffer.lock();
      try {
        myTerminalTextBuffer.resize(newSize, origin, cursorY, resizeHandler, mySelection);
        myTermSize = (Dimension) newSize.clone();

        final Dimension pixelDimension = new Dimension(getPixelWidth(), getPixelHeight());

        setPreferredSize(pixelDimension);
        if (myTerminalPanelListener != null) {
          myTerminalPanelListener.onPanelResize(pixelDimension, origin);
        }
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                updateScrolling();
              }
            });
      } finally {
        myTerminalTextBuffer.unlock();
      }
    }

    return new Dimension(getPixelWidth(), getPixelHeight());
  }
Example #30
0
  /** Is called when the applet wants to be resized. */
  @Override
  public void appletResize(int width, int height) {
    currentAppletSize.width = width;
    currentAppletSize.height = height;
    final Dimension currentSize = new Dimension(currentAppletSize.width, currentAppletSize.height);

    if (loader != null) {
      AppContext appCtxt = loader.getAppContext();
      if (appCtxt != null) appEvtQ = (java.awt.EventQueue) appCtxt.get(AppContext.EVENT_QUEUE_KEY);
    }

    final AppletPanel ap = this;
    if (appEvtQ != null) {
      appEvtQ.postEvent(
          new InvocationEvent(
              Toolkit.getDefaultToolkit(),
              new Runnable() {
                @Override
                public void run() {
                  if (ap != null) {
                    ap.dispatchAppletEvent(APPLET_RESIZE, currentSize);
                  }
                }
              }));
    }
  }