Java Direct Control.

Uploaded on:
Category: Funny / Jokes
Java Direct Control. Chris North cs3724: HCI. Java Survey. Java Swing parts, Design administrators Occasions Representation JDBC, MVC. Hit Testing. Mouse click, mouse over Which spot did client tap on? Utilizing parts: Make every speck a straightforward segment, similar to a JButton
Slide 1

Java Direct Manipulation Chris North cs3724: HCI

Slide 2

Java Review Java Swing segments, Layout administrators Events Graphics JDBC, MVC

Slide 3

Hit Testing Mouse snap, mouse over Which spot did client click on? Utilizing parts: Make every speck a straightforward segment, similar to a JButton Hit testing programmed, every segment is a subwindow Listen to every segment Receive occasion, check occasion source rectangular things, versatility, redo JComponent Using custom illustrations: Get click occasion x,y from JPanel Iterate through information structure, test for hit Or, shape.contains(x,y) Data structure for quick lookup?

Slide 4

Manipulation Dragging, extending, … MouseDrag, MouseMove occasions Using segments: mousePressed store x,y click in segment mouseDragged Calculate delta Move segment by delta Using representation: (need to delete it, repaint different illustrations, repaint new thing) Calculate delta, ascertain new thing area, store Call repaint( ) Draw new design in paintComponent( )

Slide 5

Problem Dynamic control on top of different design Need to protect (redraw) different illustrations Examples: MacDraw, powerpoint Simple arrangement: Call repaint( ) while dragging paintComponent( ) restores different design But: bunches of design, too moderate!

Slide 6

Solutions Minimize repaint rectangle: mypanel.repaint(rect) where rect is range of control paintComponent( ) handle just representation in rect Modified twofold buffering: keep up cushion for foundation illustrations Paint support to screen, then paint manip design XOR inverting so as to pain: Draw controls pixel hues drawing with XOR twice comes back to unique look graphics.setXORMode(color) graphics.setPaintMode( ) for ordinary painting

Slide 7

In JBuilder

Slide 8

Drag-n-Drop Drag and Drop API Data exchange

Slide 9

Problem: Flashing Ugly blazing when repaint: Paint foundation Redraw shapes

Slide 10

Solution: Double buffering

Slide 11

Solution: Double buffering Double cradled repaint: Draw all representation in transitory off-screen picture Paint foundation shading Paint shapes Then paint picture to JPanel Bonus: Swing does this for you! Draw representation on JPanel keeps up off-screen picture

Slide 12


View more...