In developing the GPOView browser tool flexible auto-scrolling
was an essential element of the generic interface.
This example tests auto-scroll and text editing in multiple contexts.
If you insert several lines of text you will notice that the same text element is being edited in several places. As you enter more data you will see auto-scroll shapes being triggered to control the interface.
Have a play and see what you think.
public class Text extends Helper {
protected void buildGUI() {
System.out.println("buildGUI : start");
startInvalidate(); // ensures a single update at the end
setRoot(new IAShape(this, 800, 600, 0));
IAShape root = getRootShape();
Stroke bs = new BasicStroke(1);
String initT = "This is just some editable text, so edit it.";
IAText text1 =
new IAText(this, initT, 200, 18, 0, 0, IAText.CONTENT_FONT);
text1.setMargin(8, 8);
text1.snapToText();
text1.setColors(
new Color(50, 50, 50), Color.white, bs );
text1.setEdit(true);
// auto scroll 80
IAShape as1 = new IAAutoScroll(this, text1, 80);
as1.setColors(new Color(50, 50, 50), null, bs );
as1.setMargin(1, 1);
IAShape top =
new IAShape(this, 300, 200, IAShape.GEOM_SNAP_CONTENTS);
top.setColors(new Color(50, 50, 50), Color.white, bs);
top.setMargin(5, 5);
top.addVSpace(10);
top.addNextVChild(as1);
top.addVSpace(5);
top.addNextVChild(text1);
top.addVSpace(10);
// auto scroll 270
IAShape as2 = new IAAutoScroll(this, top, 270);
as2.setColors(new Color(50, 50, 50), null, bs);
as2.setMargin(1, 1);
root.addChild(10, 10, as2);
// auto scroll 270
IAShape as3 = new IAAutoScroll(this, text1, 270);
as3.setColors(new Color(50, 50, 50), null, bs);
as3.setMargin(1, 1);
root.addChild(250, 10, as3);
// ensure display is uptodate
root.invalidate();
endInvalidate();
}
}