public float getProgress() { BoundedRangeModel model = progressBar.getModel(); float progress = (float) (model.getValue() - model.getMinimum()); float limit = (float) model.getMaximum(); return progress / limit; }
private void updateScrolling() { if (myScrollingEnabled) { myBoundedRangeModel.setRangeProperties( 0, myTermSize.height, -myTerminalTextBuffer.getHistoryBuffer().getLineCount(), myTermSize.height, false); } else { myBoundedRangeModel.setRangeProperties(0, myTermSize.height, 0, myTermSize.height, false); } }
/** * This determines the amount of the progress bar that should be filled based on the percent done * gathered from the model. This is a common operation so it was abstracted out. It assumes that * your progress bar is linear. That is, if you are making a circular progress indicator, you will * want to override this method. */ protected int getAmountFull(Insets b, int width, int height) { int amountFull = 0; BoundedRangeModel model = progressBar.getModel(); if ((model.getMaximum() - model.getMinimum()) != 0) { if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { amountFull = (int) Math.round(width * progressBar.getPercentComplete()); } else { amountFull = (int) Math.round(height * progressBar.getPercentComplete()); } } return amountFull; }
/** * Creates a JSlider built using a {@link DefaultBoundedRangeModel} and containing a {@link * MouseWheelListener} and some usual default settings * * @param model * @return the corresponding {@link JSlider} */ public static JSlider createJSlider(final BoundedRangeModel model) { final JSlider slider = new JSlider(model); slider.addMouseWheelListener( new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { slider.setValue(-e.getWheelRotation() * model.getExtent() + model.getValue()); } }); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setMajorTickSpacing(model.getMaximum() / 2); slider.setMinorTickSpacing(model.getExtent()); slider.setSnapToTicks(true); return slider; }
public synchronized void setPlayer(Player player) { if (this.player != null) { this.player.removeChangeListener(this); player.removePropertyChangeListener(this); } this.player = player; // boundedRangeModel = player == null ? null : player.getBoundedRangeModel(); boundedRangeModel = player == null ? null : player.getTimeModel(); slider.setModel(boundedRangeModel); if (player != null) { if (player.getState() >= Player.REALIZED && boundedRangeModel != null && boundedRangeModel.getMaximum() == 0) { setPlayerControlsVisible(false); } slider.setProgressModel(player.getCachingModel()); startButton.setSelected(player.isActive()); player.addChangeListener(this); player.addPropertyChangeListener(this); audioButton.setVisible(player.isAudioAvailable()); audioButton.setSelected(player.isAudioEnabled()); colorCyclingButton.setVisible( (player instanceof ColorCyclePlayer) ? ((ColorCyclePlayer) player).isColorCyclingAvailable() : false); colorCyclingButton.setSelected( (player instanceof ColorCyclePlayer) ? ((ColorCyclePlayer) player).isColorCyclingStarted() : false); validate(); repaint(); BoundedRangeModel cachingControlModel = slider.getProgressModel(); } }
// ChangeListener public void stateChanged(ChangeEvent e) { BoundedRangeModel model = progressBar.getModel(); int newRange = model.getMaximum() - model.getMinimum(); int newPercent; int oldPercent = getCachedPercent(); if (newRange > 0) { newPercent = (int) ((100 * (long) model.getValue()) / newRange); } else { newPercent = 0; } if (newPercent != oldPercent) { setCachedPercent(newPercent); progressBar.repaint(); } }
public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (boundedRangeModel != null) { int value = boundedRangeModel.getValue(); if (source == forwardButton) { boundedRangeModel.setValue( value == boundedRangeModel.getMaximum() ? boundedRangeModel.getMinimum() : value + 1); } else if (source == rewindButton) { boundedRangeModel.setValue( value == boundedRangeModel.getMinimum() ? boundedRangeModel.getMaximum() : value - 1); } else if (source == startButton) { if (startButton.isSelected() != player.isActive()) { if (startButton.isSelected()) { player.start(); } else { player.stop(); } } } else if (source == audioButton) { player.setAudioEnabled(audioButton.isSelected()); } else if (source == colorCyclingButton) { if (player instanceof ColorCyclePlayer) { ((ColorCyclePlayer) player).setColorCyclingStarted(colorCyclingButton.isSelected()); } } } }
/** * Update the visibility model with the associated JTextField (if there is one) to reflect the * current visibility as a result of changes to the document model. The bounded range properties * are updated. If the view hasn't yet been shown the extent will be zero and we just set it to be * full until determined otherwise. */ void updateVisibilityModel() { Component c = getContainer(); if (c instanceof JTextField) { JTextField field = (JTextField) c; BoundedRangeModel vis = field.getHorizontalVisibility(); int hspan = (int) getPreferredSpan(X_AXIS); int extent = vis.getExtent(); int maximum = Math.max(hspan, extent); extent = (extent == 0) ? maximum : extent; int value = maximum - extent; int oldValue = vis.getValue(); if ((oldValue + extent) > maximum) { oldValue = maximum - extent; } value = Math.max(0, Math.min(value, oldValue)); vis.setRangeProperties(value, extent, 0, maximum, false); } }
private void clearBuffer() { if (!myTerminalTextBuffer.isUsingAlternateBuffer()) { myTerminalTextBuffer.clearHistory(); if (myCoordsAccessor != null && myCoordsAccessor.getY() > 0) { TerminalLine line = myTerminalTextBuffer.getLine(myCoordsAccessor.getY() - 1); myTerminalTextBuffer.clearAll(); myCoordsAccessor.setY(0); myCursor.setY(1); myTerminalTextBuffer.addLine(line); } updateScrolling(); myClientScrollOrigin = myBoundedRangeModel.getValue(); } }
/** * Set the models value to the position of the top/left of the thumb relative to the origin of * the track. */ public void mouseDragged(MouseEvent e) { if (!XTraScrollBarUI.this.scrollbar().isEnabled() || !XTraScrollBarUI.this.isDragging()) { return; } Insets sbInsets = XTraScrollBarUI.this.scrollbar().getInsets(); BoundedRangeModel model = XTraScrollBarUI.this.scrollbar().getModel(); Rectangle thumbR = XTraScrollBarUI.this.getThumbBounds(); float trackLength; int thumbMin, thumbMax, thumbPos; if (XTraScrollBarUI.this.scrollbar().getOrientation() == JScrollBar.VERTICAL) { thumbMin = sbInsets.top; // decrButton.getY() + decrButton.getHeight(); thumbMax = XTraScrollBarUI.this.decrButton().getY() /*incrButton.getY()*/ - XTraScrollBarUI.this.getThumbBounds().height; thumbPos = Math.min(thumbMax, Math.max(thumbMin, (e.getY() - offset))); XTraScrollBarUI.this.setThumbBounds(thumbR.x, thumbPos, thumbR.width, thumbR.height); trackLength = XTraScrollBarUI.this.getTrackBounds().height; } else { thumbMin = sbInsets.left; // decrButton.getX() + decrButton.getWidth(); thumbMax = XTraScrollBarUI.this.decrButton().getX() /*incrButton.getX()*/ - XTraScrollBarUI.this.getThumbBounds().width; thumbPos = Math.min(thumbMax, Math.max(thumbMin, (e.getX() - offset))); XTraScrollBarUI.this.setThumbBounds(thumbPos, thumbR.y, thumbR.width, thumbR.height); trackLength = XTraScrollBarUI.this.getTrackBounds().width; } /* Set the scrollbars value. If the thumb has reached the end of * the scrollbar, then just set the value to its maximum. Otherwise * compute the value as accurately as possible. */ if (thumbPos == thumbMax) { XTraScrollBarUI.this.scrollbar().setValue(model.getMaximum() - model.getExtent()); } else { float valueMax = model.getMaximum() - model.getExtent(); float valueRange = valueMax - model.getMinimum(); float thumbValue = thumbPos - thumbMin; float thumbRange = thumbMax - thumbMin; int value = (int) (0.5 + ((thumbValue / thumbRange) * valueRange)); XTraScrollBarUI.this.scrollbar().setValue(value + model.getMinimum()); } }
private void moveScrollBar(int k) { myBoundedRangeModel.setValue(myBoundedRangeModel.getValue() + k); }
private void scrollToBottom() { myBoundedRangeModel.setValue(myTermSize.height); }
public void init() { initFont(); setUpClipboard(); setPreferredSize(new Dimension(getPixelWidth(), getPixelHeight())); setFocusable(true); enableInputMethods(true); setDoubleBuffered(true); setFocusTraversalKeysEnabled(false); addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(final MouseEvent e) { if (!isLocalMouseAction(e)) { return; } final Point charCoords = panelToCharCoords(e.getPoint()); if (mySelection == null) { // prevent unlikely case where drag started outside terminal panel if (mySelectionStartPoint == null) { mySelectionStartPoint = charCoords; } mySelection = new TerminalSelection(new Point(mySelectionStartPoint)); } repaint(); mySelection.updateEnd(charCoords); if (mySettingsProvider.copyOnSelect()) { handleCopy(false); } if (e.getPoint().y < 0) { moveScrollBar((int) ((e.getPoint().y) * SCROLL_SPEED)); } if (e.getPoint().y > getPixelHeight()) { moveScrollBar((int) ((e.getPoint().y - getPixelHeight()) * SCROLL_SPEED)); } } }); addMouseWheelListener( new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (isLocalMouseAction(e)) { int notches = e.getWheelRotation(); moveScrollBar(notches); } } }); addMouseListener( new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (e.getClickCount() == 1) { mySelectionStartPoint = panelToCharCoords(e.getPoint()); mySelection = null; repaint(); } } } @Override public void mouseReleased(final MouseEvent e) { requestFocusInWindow(); repaint(); } @Override public void mouseClicked(final MouseEvent e) { requestFocusInWindow(); if (e.getButton() == MouseEvent.BUTTON1 && isLocalMouseAction(e)) { int count = e.getClickCount(); if (count == 1) { // do nothing } else if (count == 2) { // select word final Point charCoords = panelToCharCoords(e.getPoint()); Point start = SelectionUtil.getPreviousSeparator(charCoords, myTerminalTextBuffer); Point stop = SelectionUtil.getNextSeparator(charCoords, myTerminalTextBuffer); mySelection = new TerminalSelection(start); mySelection.updateEnd(stop); if (mySettingsProvider.copyOnSelect()) { handleCopy(false); } } else if (count == 3) { // select line final Point charCoords = panelToCharCoords(e.getPoint()); int startLine = charCoords.y; while (startLine > -getScrollBuffer().getLineCount() && myTerminalTextBuffer.getLine(startLine - 1).isWrapped()) { startLine--; } int endLine = charCoords.y; while (endLine < myTerminalTextBuffer.getHeight() && myTerminalTextBuffer.getLine(endLine).isWrapped()) { endLine++; } mySelection = new TerminalSelection(new Point(0, startLine)); mySelection.updateEnd(new Point(myTermSize.width, endLine)); if (mySettingsProvider.copyOnSelect()) { handleCopy(false); } } } else if (e.getButton() == MouseEvent.BUTTON2 && mySettingsProvider.pasteOnMiddleMouseClick() && isLocalMouseAction(e)) { handlePaste(); } else if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu popup = createPopupMenu(); popup.show(e.getComponent(), e.getX(), e.getY()); } repaint(); } }); addComponentListener( new ComponentAdapter() { @Override public void componentResized(final ComponentEvent e) { sizeTerminalFromComponent(); } }); addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myCursor.cursorChanged(); } @Override public void focusLost(FocusEvent e) { myCursor.cursorChanged(); } }); myBoundedRangeModel.addChangeListener( new ChangeListener() { public void stateChanged(final ChangeEvent e) { myClientScrollOrigin = myBoundedRangeModel.getValue(); repaint(); } }); createRepaintTimer(); }
protected void runTestGL( final GLCapabilities caps, final FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { final JFrame frame = new JFrame("Bug816: " + this.getTestMethodName()); Assert.assertNotNull(frame); final Container framePane = frame.getContentPane(); final GLCanvas glCanvas1 = new GLCanvas(caps); Assert.assertNotNull(glCanvas1); final GLCanvas glCanvas2; if (twoCanvas) { glCanvas2 = new GLCanvas(caps); Assert.assertNotNull(glCanvas2); } else { glCanvas2 = null; } final Dimension glcDim = new Dimension(width / 2, height); final Dimension frameDim = new Dimension(twoCanvas ? width + 64 : width / 2 + 64, height + 64); setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); switch (frameLayout) { case None: { framePane.add(glCanvas1); } break; case Flow: { final Container c = new Container(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case DoubleBorderCenterSurrounded: { final Container c = new Container(); c.setLayout(new BorderLayout()); c.add(new Button("north"), BorderLayout.NORTH); c.add(new Button("south"), BorderLayout.SOUTH); c.add(new Button("east"), BorderLayout.EAST); c.add(new Button("west"), BorderLayout.WEST); if (twoCanvas) { final Container c2 = new Container(); c2.setLayout(new GridLayout(1, 2)); c2.add(glCanvas1); c2.add(glCanvas2); c.add(c2, BorderLayout.CENTER); } else { c.add(glCanvas1, BorderLayout.CENTER); } framePane.setLayout(new BorderLayout()); framePane.add(new Button("NORTH"), BorderLayout.NORTH); framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); framePane.add(new Button("EAST"), BorderLayout.EAST); framePane.add(new Button("WEST"), BorderLayout.WEST); framePane.add(c, BorderLayout.CENTER); } break; case Box: { final Container c = new Container(); c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); c.add(glCanvas1); if (twoCanvas) { c.add(glCanvas2); } framePane.add(c); } break; case Split: { final Dimension sbDim = new Dimension(16, 16); final JScrollPane vsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); { final JScrollBar vsb = vsp.getVerticalScrollBar(); vsb.setPreferredSize(sbDim); final BoundedRangeModel model = vsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); vsb.setEnabled(true); } final JScrollPane hsp = new JScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); { final JScrollBar hsb = hsp.getHorizontalScrollBar(); hsb.setPreferredSize(sbDim); final BoundedRangeModel model = hsb.getModel(); model.setMinimum(0); model.setMaximum(100); model.setValue(50); model.setExtent(1); hsb.setEnabled(true); } final JSplitPane horizontalSplitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, twoCanvas ? glCanvas2 : vsp, glCanvas1); horizontalSplitPane.setResizeWeight(0.5); final JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, horizontalSplitPane, hsp); verticalSplitPane.setResizeWeight(0.5); framePane.add(verticalSplitPane); } break; } final GearsES2 demo1 = new GearsES2(swapInterval); glCanvas1.addGLEventListener(demo1); if (twoCanvas) { final RedSquareES2 demo2 = new RedSquareES2(swapInterval); glCanvas2.addGLEventListener(demo2); } final Animator animator = new Animator(); animator.add(glCanvas1); if (twoCanvas) { animator.add(glCanvas2); } final QuitAdapter quitAdapter = new QuitAdapter(); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas1).addTo(frame); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { if (resizeByComp) { frame.pack(); } else { setFrameSize(frame, true, frameDim); } frame.setVisible(true); } }); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); if (twoCanvas) { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); } animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); System.err.println( "canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } Thread.sleep(Math.max(1000, duration / 2)); if (null != rwsize) { final Dimension compRSizeHalf = new Dimension(rwsize.width / 2, rwsize.height); final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64 : rwsize.width / 2 + 64, rwsize.height + 64); if (resizeByComp) { setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); } else { setFrameSize(frame, true, frameRSizeHalf); } System.err.println( "resize canvas1 pos/siz: " + glCanvas1.getX() + "/" + glCanvas1.getY() + " " + glCanvas1.getSurfaceWidth() + "x" + glCanvas1.getSurfaceHeight()); if (twoCanvas) { System.err.println( "resize canvas2 pos/siz: " + glCanvas2.getX() + "/" + glCanvas2.getY() + " " + glCanvas2.getSurfaceWidth() + "x" + glCanvas2.getSurfaceHeight()); } } final long t0 = System.currentTimeMillis(); long t1 = t0; while (!quitAdapter.shouldQuit() && t1 - t0 < duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); } Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas1); if (twoCanvas) { Assert.assertNotNull(glCanvas2); } else { Assert.assertNull(glCanvas2); } Assert.assertNotNull(animator); animator.stop(); Assert.assertFalse(animator.isAnimating()); Assert.assertFalse(animator.isStarted()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.setVisible(false); } }); Assert.assertEquals(false, frame.isVisible()); javax.swing.SwingUtilities.invokeAndWait( new Runnable() { public void run() { frame.remove(glCanvas1); if (twoCanvas) { frame.remove(glCanvas2); } frame.dispose(); } }); }
public void adjustmentValueChanged(AdjustmentEvent e) { if (!brm.getValueIsAdjusting()) { if (wasAtBottom) brm.setValue(brm.getMaximum()); } else wasAtBottom = ((brm.getValue() + brm.getExtent()) == brm.getMaximum()); }
/** Run the task. */ public void run() { final BoundedRangeModel model = progressBar.getModel(); switch (task) { case -LABEL: { value = description.getText(); return; } case +LABEL: { description.setText((String) value); return; } case PROGRESS: { model.setValue(((Integer) value).intValue()); progressBar.setIndeterminate(false); return; } case STARTED: { model.setRangeProperties(0, 1, 0, 100, false); window.setVisible(true); break; // Need further action below. } case COMPLETE: { model.setRangeProperties(100, 1, 0, 100, false); window.setVisible(warningArea != null); cancel.setEnabled(false); break; // Need further action below. } } /* * Some of the tasks above requires an action on the window, which may be a JDialog or * a JInternalFrame. We need to determine the window type before to apply the action. */ synchronized (ProgressWindow.this) { if (window instanceof JDialog) { final JDialog window = (JDialog) ProgressWindow.this.window; switch (task) { case -TITLE: { value = window.getTitle(); return; } case +TITLE: { window.setTitle((String) value); return; } case STARTED: { window.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); return; } case COMPLETE: { window.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); return; } case DISPOSE: { window.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); if (warningArea == null || !window.isVisible()) { window.dispose(); } return; } } } else { final JInternalFrame window = (JInternalFrame) ProgressWindow.this.window; switch (task) { case -TITLE: { value = window.getTitle(); return; } case +TITLE: { window.setTitle((String) value); return; } case STARTED: { window.setClosable(false); return; } case COMPLETE: { window.setClosable(true); return; } case DISPOSE: { window.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); if (warningArea == null || !window.isVisible()) { window.dispose(); } return; } } } /* * Si la tâche spécifiée n'est aucune des tâches énumérées ci-haut, * on supposera que l'on voulait afficher un message d'avertissement. */ if (warningArea == null) { final JTextArea warningArea = new JTextArea(); final JScrollPane scroll = new JScrollPane(warningArea); final JPanel namedArea = new JPanel(new BorderLayout()); ProgressWindow.this.warningArea = warningArea; warningArea.setFont(Font.getFont("Monospaced")); warningArea.setEditable(false); namedArea.setBorder(BorderFactory.createEmptyBorder(0, HMARGIN, VMARGIN, HMARGIN)); namedArea.add(new JLabel(getString(VocabularyKeys.WARNING)), BorderLayout.NORTH); namedArea.add(scroll, BorderLayout.CENTER); content.add(namedArea, BorderLayout.CENTER); if (window instanceof JDialog) { final JDialog window = (JDialog) ProgressWindow.this.window; window.setResizable(true); } else { final JInternalFrame window = (JInternalFrame) ProgressWindow.this.window; window.setResizable(true); } window.setSize(WIDTH, HEIGHT + WARNING_HEIGHT); window.setVisible(true); // Seems required in order to force relayout. } final JTextArea warningArea = (JTextArea) ProgressWindow.this.warningArea; warningArea.append((String) value); } }
/** * Adjusts the allocation given to the view to be a suitable allocation for a text field. If the * view has been allocated more than the preferred span vertically, the allocation is changed to * be centered vertically. Horizontally the view is adjusted according to the horizontal alignment * property set on the associated JTextField (if that is the type of the hosting component). * * @param a the allocation given to the view, which may need to be adjusted. * @return the allocation that the superclass should use. */ protected Shape adjustAllocation(Shape a) { if (a != null) { Rectangle bounds = a.getBounds(); int vspan = (int) getPreferredSpan(Y_AXIS); int hspan = (int) getPreferredSpan(X_AXIS); if (bounds.height != vspan) { int slop = bounds.height - vspan; bounds.y += slop / 2; bounds.height -= slop; } // horizontal adjustments Component c = getContainer(); if (c instanceof JTextField) { JTextField field = (JTextField) c; BoundedRangeModel vis = field.getHorizontalVisibility(); int max = Math.max(hspan, bounds.width); int value = vis.getValue(); int extent = Math.min(max, bounds.width - 1); if ((value + extent) > max) { value = max - extent; } vis.setRangeProperties(value, extent, vis.getMinimum(), max, false); if (hspan < bounds.width) { // horizontally align the interior int slop = bounds.width - 1 - hspan; int align = ((JTextField) c).getHorizontalAlignment(); if (Utilities.isLeftToRight(c)) { if (align == LEADING) { align = LEFT; } else if (align == TRAILING) { align = RIGHT; } } else { if (align == LEADING) { align = RIGHT; } else if (align == TRAILING) { align = LEFT; } } switch (align) { case SwingConstants.CENTER: bounds.x += slop / 2; bounds.width -= slop; break; case SwingConstants.RIGHT: bounds.x += slop; bounds.width -= slop; break; } } else { // adjust the allocation to match the bounded range. bounds.width = hspan; bounds.x -= vis.getValue(); } } return bounds; } return null; }