/** * Tests for <code>PlainView</code> repaints more lines than necessary. * * <p>If a character (not a new line) is inserted into document, document structure will not * change, or in other words the number of text lines will stay the same. In this case only the * modified line needs to be repainted but <code>PlainView</code> repaints all following lines as * well. */ public void testInsertUpdateExtraRepaint() throws BadLocationException { doc.insertString(0, "1:0123\n2:\n3:abcdefg", null); view.updateMetrics(); doc.insertString(0, "^", null); view.insertUpdate(event, shape, null); lineRange.check(0, 0, shape, container); }
/** * Tests for calling <code>nextTabStop()</code> leaves <code>PlainView.metrics</code> field <code> * null</code>. This is because <code>nextTabStop()</code> forwards to <code>paintParams</code> * and updates <code>metrics</code> there, and <code>setSize()</code> doesn't update the field in * the <code>PlainView</code>. */ public void testNextTabStop05() { assertNull(view.metrics); if (isHarmony()) { // Call to nextTabStop will lead to updateMetrics() assertTrue("nextTabStop() must return value > 0", view.nextTabStop(0, 0) > view.getTabSize()); } view.setSize(100, 200); assertNotNull("Metrics must be not null after setSize", view.metrics); }
protected final void finalize() { try { super.finalize(); } catch (Throwable t) { t.printStackTrace(); } }
@Override public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) { super.changedUpdate(e, a, f); JavaDocument d = (JavaDocument) e.getDocument(); if (d.isNeedsRedraw()) { getContainer().repaint(); d.setNeedsRedraw(false); } }
/** * Gives notification that something was removed from the document in a location that this view is * responsible for. * * @param changes the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children * @see View#removeUpdate */ public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f) { super.removeUpdate(changes, adjustAllocation(a), f); updateVisibilityModel(); }
/** * Renders using the given rendering surface and area on that surface. The view may need to do * layout and create child views to enable itself to render into the given allocation. * * @param g the rendering surface to use * @param a the allocated region to render into * @see View#paint */ public void paint(Graphics g, Shape a) { Rectangle r = (Rectangle) a; g.clipRect(r.x, r.y, r.width, r.height); super.paint(g, a); }
/** * Tests for <code>PlainView.insertUpdate</code> throws NPE. * * <p>If a change occured outside the widest line and document structure was not changed, <code> * insertUpdate</code> throws NPE when processing the notification. */ public void testInsertUpdateNPE() throws BadLocationException { doc.insertString(0, "1:0123\n2:\n3:abcdefg", null); view.updateMetrics(); doc.insertString(0, "^", null); view.insertUpdate(event, shape, null); }