java direct manipulation n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Java Direct Manipulation PowerPoint Presentation
Download Presentation
Java Direct Manipulation

Loading in 2 Seconds...

play fullscreen
1 / 11

Java Direct Manipulation - PowerPoint PPT Presentation


  • 282 Views
  • Uploaded on

Java Direct Manipulation. Chris North cs3724: HCI. Java Review. Java Swing components, Layout managers Events Graphics JDBC, MVC. Hit Testing. Mouse click, mouse over Which dot did user click on? Using components: Make each dot a simple component, like a JButton

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Java Direct Manipulation' - adamdaniel


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
java direct manipulation

Java Direct Manipulation

Chris North

cs3724: HCI

java review
Java Review
  • Java
  • Swing components, Layout managers
  • Events
  • Graphics
  • JDBC, MVC
hit testing
Hit Testing
  • Mouse click, mouse over
  • Which dot did user click on?
  • Using components:
      • Make each dot a simple component, like a JButton
      • Hit testing automatic, each component is a subwindow
      • Listen to each component
      • Receive event, check event source
      • rectangular items, scalability, customize JComponent
  • Using custom graphics:
      • Get click event x,y from JPanel
      • Iterate through data structure, test for hit
      • Or, shape.contains(x,y)
      • Data structure for fast lookup?
manipulation
Manipulation
  • Dragging, stretching, …
  • MouseDrag, MouseMove events
  • Using components:
      • mousePressed store x,y click in component
      • mouseDragged
        • Calculate delta
        • Move component by delta
  • Using graphics:
      • (need to erase it, repaint other graphics, repaint new item)
      • Calculate delta, calculate new item location, store
      • Call repaint( )
      • Draw new graphics in paintComponent( )
problem
Problem
  • Dynamic manipulation on top of other graphics
      • Need to preserve (redraw) other graphics
      • Examples: MacDraw, powerpoint
  • Simple solution:
      • Call repaint( ) while dragging
      • paintComponent( ) restores other graphics
      • But: lots of graphics, too slow!
solutions
Solutions
  • Minimize repaint rectangle:
      • mypanel.repaint(rect) where rect is area of manipulation
      • paintComponent( ) process only graphics in rect
  • Modified double buffering:
      • maintain buffer for background graphics
      • Paint buffer to screen, then paint manip graphics
  • XOR painting:
      • Draw manipulations by inverting pixel colors
      • drawing with XOR twice returns to original look
      • graphics.setXORMode(color)
      • graphics.setPaintMode( ) for normal painting
drag n drop
Drag-n-Drop
  • Drag and Drop API
  • Data transfer
problem flashing
Problem: Flashing
  • Ugly flashing when repaint:
      • Paint background
      • Redraw shapes
solution double buffering1
Solution: Double buffering
  • Double buffered repaint:
      • Draw all graphics in temporary off-screen image
          • Paint background color
          • Paint shapes
      • Then paint image to JPanel
  • Bonus: Swing does this for you!
      • Draw graphics on JPanel
      • JPanel maintains off-screen image