Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Resizing works, but scrolling "smears" image.(Issue with Resizing an image versus Scrolling it.)
| |
Re: Resizing works, but scrolling "smears" image. [message #1057499 is a reply to message #1053685] |
Wed, 08 May 2013 12:33 |
Robert Adamson Messages: 9 Registered: March 2013 |
Junior Member |
|
|
Thanks for Responding, here is the code for the Paint Event.
// Handle Paint event.s
canvas.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
GC gc = e.gc;
gc.drawImage (image, origin.x, origin.y);
Rectangle rect = image.getBounds ();
Rectangle client = canvas.getClientArea ();
int marginWidth = client.width - rect.width;
if (marginWidth > 0) {
gc.fillRectangle (rect.width, 0, marginWidth, client.height);
}
int marginHeight = client.height - rect.height;
if (marginHeight > 0) {
gc.fillRectangle (0, rect.height, client.width, marginHeight);
}
// TODO is this where we can tell it to repaint our plotted hexes ???
// redraw any plotted hexes.
// Need to iterate though the list and mark the map again.
if (currUnit != null && plotting) {
Collection<PlottedHex> tempList = currUnit.getListValues();
PlottedHex[] ph = tempList.toArray( new PlottedHex[20] );
PlottedHex tempHex = null;
int i=0;
while ( (i < ph.length) && (ph[i] != null) ) {
tempHex = ph[i];
// now mark hex once we have the X and Y
GC myGC = new GC(canvas);
;
Color frgdColor = new Color(display, 0, 180, 10); // bright green
Color oldFrgd = myGC.getForeground(); // save setting.
myGC.setForeground(frgdColor);
myGC.setLineWidth(2);
myGC.drawOval(tempHex.getX() - 10, tempHex.getY(), 10, 10);
myGC.setForeground(oldFrgd); // restore it.
myGC.dispose();
i++;
}
}
}
});
|
|
|
Re: Resizing works, but scrolling "smears" image. [message #1057681 is a reply to message #1053685] |
Wed, 08 May 2013 12:33 |
Robert Adamson Messages: 9 Registered: March 2013 |
Junior Member |
|
|
Thanks for Responding, here is the code for the Paint Event.
// Handle Paint event.s
canvas.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
GC gc = e.gc;
gc.drawImage (image, origin.x, origin.y);
Rectangle rect = image.getBounds ();
Rectangle client = canvas.getClientArea ();
int marginWidth = client.width - rect.width;
if (marginWidth > 0) {
gc.fillRectangle (rect.width, 0, marginWidth, client.height);
}
int marginHeight = client.height - rect.height;
if (marginHeight > 0) {
gc.fillRectangle (0, rect.height, client.width, marginHeight);
}
// TODO is this where we can tell it to repaint our plotted hexes ???
// redraw any plotted hexes.
// Need to iterate though the list and mark the map again.
if (currUnit != null && plotting) {
Collection<PlottedHex> tempList = currUnit.getListValues();
PlottedHex[] ph = tempList.toArray( new PlottedHex[20] );
PlottedHex tempHex = null;
int i=0;
while ( (i < ph.length) && (ph[i] != null) ) {
tempHex = ph[i];
// now mark hex once we have the X and Y
GC myGC = new GC(canvas);
;
Color frgdColor = new Color(display, 0, 180, 10); // bright green
Color oldFrgd = myGC.getForeground(); // save setting.
myGC.setForeground(frgdColor);
myGC.setLineWidth(2);
myGC.drawOval(tempHex.getX() - 10, tempHex.getY(), 10, 10);
myGC.setForeground(oldFrgd); // restore it.
myGC.dispose();
i++;
}
}
}
});
|
|
| | |
Goto Forum:
Current Time: Mon Sep 23 20:10:18 GMT 2024
Powered by FUDForum. Page generated in 0.03947 seconds
|