Hello Don,
Here's what we got working in the end. The following invert() method
is called for each OMText item and it's corresponding OMRaster item.
The OMText one just inverts the foreground and background colour.
The OMRaster is inverted by replacing it with an ImageIcon made from
an inverted copy of the current image.
Invert also uses the AppObject property to flag whether the item
is selected or not.
The Invert class uses Java Advanced Imaging to invert the image.
private void invert(OMGraphic omg) { ///////////////////////////////// invert()
//
// Invert the colours of this OMGraphic. The graphic //
// might be an OMRaster or an OMText and we have //
// different means for each. //
//
if (omg != null) { //
if (omg instanceof OMRaster) { // If it's an OMRaster
OMRaster g = (OMRaster)omg; // cast to raster
Image src = g.getImage(); // get the icon image
g.setImageIcon(new ImageIcon(Inverter.invert(src))); // set the inverted icon
} //
else if (omg instanceof OMText) { // Else if an OMText
OMText t = (OMText)omg; // cast to text
int colour = t.getLineColor().getRGB(); // get text color
t.setLinePaint(new Color(colour ^ 0x00ffffff)); // invert text
Color background = (Color)t.getBoundsFillColor(); // get background colour
if (background.getAlpha() != 0) { // if it is non-transparent
colour = background.getRGB(); // get background color
t.setFillPaint(new Color(colour ^ 0x00ffffff)); // invert background and edge
} //
} //
} //
if (omg.getAppObject() == null) omg.setAppObject(this); // If not selected, select
else omg.setAppObject(null); // Else deselect
//
} /////////////////////////////////////////////////////////////// End of invert()
import java.awt.*;
import java.awt.image.*;
import java.awt.image.renderable.*;
import javax.media.jai.*;
public class Inverter {
public Inverter() {
}
public static Image invert(Image image) {
BufferedImage image2 = new BufferedImage(image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_RGB);
Graphics g = image2.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
ParameterBlock pb = new ParameterBlock();
pb.addSource(image2);
return JAI.create("invert", pb).getAsBufferedImage();
}
}
best regards,
Adrian
- -------------------------------------------
Adrian Lumsden Product Specialist
Scientific Software and Systems Limited
DDI: +64 4 917-6680
Tel: +64 4 917-6670
Fax: +64 4 917-6671
E-mail: Adrian.Lumsden@sss.co.nz
Visit us on the Web at: http://www.sss.co.nz
_____________________________________________
This e-mail passed SSS's content security scan.
It is covered by the confidentiality clauses at
http://www.sss.co.nz/content_and_confidentiality
-----Original Message-----
From: owner-openmap-users@bbn.com [mailto:owner-openmap-users@bbn.com]On
Behalf Of Don Dietrick
Sent: Saturday, 6 July 2002 04:29
To: Adrian Lumsden
Cc: OpenMap-Users
Subject: Re: ImageFilter use in OMRasterObject
Hi Adrian,
There are couple of things you can do. The "Shape" of an OMRasterObject
is a rectangle around the image. You could modify the render method of
OMRasterObject to draw this rectangle around the selected image (which
might be a good thing for us to add as the default action, actually).
If you want to go the XOR paint route, I think you can also modify the
render method to set the XOR mode of the graphics if the OMRasterObject
is selected. The XOR mode takes a single Color, though, so it might not
give you the results you think it will ( I really don't know either
way). The EditableOMGraphic uses the XOR mode for drawing changing
OMGraphics, so you can check that class out for an example of using that
mode.
Hope this helps,
Don
On Wednesday, July 3, 2002, at 07:56 PM, Adrian Lumsden wrote:
>
> I have developed a layer which displays text and an icon for points
> which have been selected by the user from a database. Either or
> both the text and icon are displayed.
>
> I want to allow them to pick items from the map using the mouse and I
> want to be able to show them which items have been selected.
>
> I can alter the text display of selected items by using
> setBoundsLineCOlor.
>
> I'd like to change the icon presentation and have been trying to do
> this with setImagFilter() to XOR the colours with a mask colour
> (so that I can XOR them back again).
>
> Does anyone have any hints or examples of doing this please?
>
>
> regards,
>
> Adrian
>
> - -------------------------------------------
> Adrian Lumsden Product Specialist
> Scientific Software and Systems Limited
>
> DDI: +64 4 917-6680
> Tel: +64 4 917-6670
> Fax: +64 4 917-6671
> E-mail: Adrian.Lumsden@sss.co.nz
>
> Visit us on the Web at: http://www.sss.co.nz
> _____________________________________________
>
> This e-mail passed SSS's content security scan.
> It is covered by the confidentiality clauses at
> http://www.sss.co.nz/content_and_confidentiality
>
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"] -- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Sun Jul 7 16:35:50 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT