Package javax.swing

Examples of javax.swing.JViewport


    // TF:10/03/2009:Added an efficiency measure of only painting the empty rows if they're needed
    int topRow;
    Rectangle parentVisibleRect = null;
    if (this.getParent() instanceof JViewport) {
      JViewport port = (JViewport)this.getParent();
      topRow = this.rowAtPoint(new Point(0, port.getViewRect().y));
      parentVisibleRect = port.getVisibleRect();
    }
    else {
      topRow = this.rowAtPoint(this.getCellRect(0, 0, true).getLocation());
    }
    if (topRow + visibleRows < rowCount) {
View Full Code Here


            left += table.getColumnModel().getColumn(1).getWidth();
        }
        int right = table.getColumnModel().getColumn(column - 1).getWidth() + left;
        int bottom = 0;
        if (table.getParent() instanceof JViewport) {
            JViewport sp = (JViewport) table.getParent();
            bottom = sp.getHeight();
        }
        else {
            bottom = table.getHeight();
        }
        if (table.getTableHeader() != null) {
View Full Code Here

     *            the row to scroll to
     * @return
     */

    public static void scrollToRow(JTable t, int r) {
        JViewport viewport = (JViewport) t.getParent();
        viewport.setViewPosition(new java.awt.Point(0, t.getRowHeight() * r));
    }
View Full Code Here

    // If the table allows append then ensure there is sufficient space in
    // the viewport to allow append click
    if (((ArrayFieldModel) view.getModel()).allowsAppend()) {
      sp.setOpaque(false);
      sp.setViewport(new JViewport() {

        private static final long serialVersionUID = 1198452025480683030L;

        public Dimension getViewSize() {
          Dimension d = super.getViewSize();
View Full Code Here

        }
        else if (this._component instanceof JTree){
            JTree jt = (JTree)this._component;
            if (!(jt.getParent() instanceof JViewport))
                return;
            JViewport viewport = (JViewport)jt.getParent();
            TreePath tp = jt.getPathForRow(line);
            java.awt.Rectangle rect = jt.getPathBounds(tp);
            java.awt.Rectangle viewRect = viewport.getViewRect();
            rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y);
            viewport.scrollRectToVisible(rect);

        }
    }
View Full Code Here

    } else if (mouseButton == MouseEvent.BUTTON2 || mouseButton == MouseEvent.BUTTON1
        && (event.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
      // Scroll with middle mouse button
      int dx = event.getX() - mouseInitialScreenLocation.x;
      int dy = event.getY() - mouseInitialScreenLocation.y;
      JViewport mapViewPort = mapScrollPane.getViewport();
      Point currentPosition = mapViewPort.getViewPosition();
      mouseInitialScreenLocation = new Point(event.getX() - dx, event.getY() - dy);

      Point newPosition = new Point(currentPosition.x - dx, currentPosition.y - dy);

      // Take into account map boundaries in order to prevent
      // scrolling past them
      int maxX = mapView.getWidth() - mapViewPort.getWidth();
      int maxY = mapView.getHeight() - mapViewPort.getHeight();
      newPosition.x = Math.min(maxX, Math.max(0, newPosition.x));
      newPosition.y = Math.min(maxY, Math.max(0, newPosition.y));

      mapViewPort.setViewPosition(newPosition);
    } else if (mouseButton == MouseEvent.BUTTON1) {
      switch (currentPointerState) {
      case PS_PAINT:
        paintEdit.setPresentationName(TOOL_PAINT);
        if (layer instanceof TileLayer) {
View Full Code Here

    // This can currently only happen when the map changes size
    String s = String.valueOf((int) (mapView.getZoom() * 100)) + "%";
    zoomLabel.setText(s);

    // Restore the midpoint
    JViewport mapViewPort = mapScrollPane.getViewport();
    Rectangle viewRect = mapViewPort.getViewRect();
    int absMidX = Math.max(0, Math.round(relativeMidX * mapView.getWidth()) - viewRect.width / 2);
    int absMidY = Math.max(0, Math.round(relativeMidY * mapView.getHeight()) - viewRect.height / 2);
    mapViewPort.setViewPosition(new Point(absMidX, absMidY));
  }
View Full Code Here

    updateLayerOperations();
  }

  @Override
  public void stateChanged(ChangeEvent e) {
    JViewport mapViewport = mapScrollPane.getViewport();

    if (e.getSource() == opacitySlider) {
      if (currentMap != null && currentLayer >= 0) {
        MapLayer layer = getCurrentLayer();
        layer.setOpacity(opacitySlider.getValue() / 100.0f);

        /*
         * MapLayerStateEdit mlse = new MapLayerStateEdit(currentMap);
         * mlse.setPresentationName("Opacity Change");
         * undoSupport.postEdit(mlse);
         */
      }
    } else if (e.getSource() == mapViewport && mapView != null) {
      // Store the point in the middle for zooming purposes
      Rectangle viewRect = mapViewport.getViewRect();
      relativeMidX = Math.min(1, (viewRect.x + viewRect.width / 2) / (float) mapView.getWidth());
      relativeMidY = Math.min(1, (viewRect.y + viewRect.height / 2) / (float) mapView.getHeight());
    }
  }
View Full Code Here

      mapView.addComponentListener(this);
      mapView.setGridOpacity(display.getInt("gridOpacity", 255));
      mapView.setAntialiasGrid(display.getBoolean("gridAntialias", true));
      mapView.setGridColor(new Color(display.getInt("gridColor", MapView.DEFAULT_GRID_COLOR.getRGB())));
      mapView.setShowGrid(display.getBoolean("showGrid", false));
      JViewport mapViewport = new JViewport();
      mapViewport.setView(mapView);
      mapViewport.addChangeListener(this);
      mapScrollPane.setViewport(mapViewport);
      setCurrentPointerState(PS_PAINT);

      currentMap.addMapChangeListener(this);
View Full Code Here

            left += table.getColumnModel().getColumn(1).getWidth();
        }
        int right = table.getColumnModel().getColumn(column - 1).getWidth() + left;
        int bottom = 0;
        if (table.getParent() instanceof JViewport) {
            JViewport sp = (JViewport) table.getParent();
            bottom = sp.getHeight();
        }
        else {
            bottom = table.getHeight();
        }
        if (table.getTableHeader() != null) {
View Full Code Here

TOP

Related Classes of javax.swing.JViewport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.