![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2011
Location: Liège, Belgium
Posts: 18
![]() |
Hi,
I'm encoutering some issue when I try to do a simple text layer for providing shortcuts to user. I'm not able to switch visibility between two annotation using their visible attribute. When I do setCollapsed with false, the two annotations are visible. Here is the code of my layer: Code:
public class HelpLayer extends RenderableLayer{
private Color color = Color.white;
private String collapsedText = "Press 'h' to show keyboard shortcuts";
private String expandedText = "Press 'h' to hide keyboard shortcuts\nexpanded";
ScreenAnnotation collapsedAnnotation;
ScreenAnnotation expandedAnnotation;
private boolean collapsed = true;
public HelpLayer() {
this.collapsedAnnotation = new ScreenAnnotation(collapsedText, new Point(50, 50));
AnnotationAttributes annotationAttributes = new AnnotationAttributes();
annotationAttributes.setTextColor(this.color);
annotationAttributes.setImageSource(null);
annotationAttributes.setFrameShape(AVKey.SHAPE_NONE);
annotationAttributes.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
this.collapsedAnnotation.setAttributes(annotationAttributes);
this.addRenderable(this.collapsedAnnotation);
this.expandedAnnotation = new ScreenAnnotation(expandedText, new Point(50, 50));
annotationAttributes = new AnnotationAttributes();
annotationAttributes.setTextColor(this.color);
annotationAttributes.setImageSource(null);
annotationAttributes.setFrameShape(AVKey.SHAPE_NONE);
annotationAttributes.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
this.expandedAnnotation.setAttributes(annotationAttributes);
this.addRenderable(this.expandedAnnotation);
update();
}
private synchronized void update()
{
collapsedAnnotation.getAttributes().setVisible(collapsed);
expandedAnnotation.getAttributes().setVisible(!collapsed);
}
/**
* @return the collapsed
*/
public boolean isCollapsed() {
return collapsed;
}
/**
* @param collapsed the collapsed to set
*/
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
update();
}
}
|
|
|
|
|
|
#2 |
|
Member
Join Date: Jan 2012
Posts: 94
![]() |
Hi there,
I tried your class and never experience both ScreenAnnotations at the same time. However, often changing the Annotation has no visible effect at all, so I needed to add a redrawNow() (redraw() might work, too) to see the change immediately. Maybe this will solve your problem, too? Here are my changes: Code:
public class HelpLayer extends RenderableLayer{
private WorldWindow wwd;
private Color color = Color.white;
private String collapsedText = "Press 'h' to show keyboard shortcuts";
private String expandedText = "Press 'h' to hide keyboard shortcuts\nexpanded";
ScreenAnnotation collapsedAnnotation;
ScreenAnnotation expandedAnnotation;
private boolean collapsed = true;
public HelpLayer(WorldWindow wwd) {
this.wwd = wwd;
this.collapsedAnnotation = new ScreenAnnotation(collapsedText, new Point(50, 50));
AnnotationAttributes annotationAttributes = new AnnotationAttributes();
annotationAttributes.setTextColor(this.color);
annotationAttributes.setImageSource(null);
annotationAttributes.setFrameShape(AVKey.SHAPE_NONE);
annotationAttributes.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
this.collapsedAnnotation.setAttributes(annotationAttributes);
this.addRenderable(this.collapsedAnnotation);
this.expandedAnnotation = new ScreenAnnotation(expandedText, new Point(50, 50));
annotationAttributes = new AnnotationAttributes();
annotationAttributes.setTextColor(this.color);
annotationAttributes.setImageSource(null);
annotationAttributes.setFrameShape(AVKey.SHAPE_NONE);
annotationAttributes.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
this.expandedAnnotation.setAttributes(annotationAttributes);
this.addRenderable(this.expandedAnnotation);
update();
}
private synchronized void update()
{
collapsedAnnotation.getAttributes().setVisible(collapsed);
expandedAnnotation.getAttributes().setVisible(!collapsed);
wwd.redrawNow();
}
/**
* @return the collapsed
*/
public boolean isCollapsed() {
return collapsed;
}
/**
* @param collapsed the collapsed to set
*/
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
update();
}
}
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2011
Location: Liège, Belgium
Posts: 18
![]() |
It works! Thx a lot.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GetCurrentPosition question... | ruso | Development Help | 19 | 08-24-2011 04:07 PM |
| Problems displaying a layer from cache | jpralle | Development Help | 0 | 11-02-2010 01:27 PM |
| Plugin: My favorite Icons - Add Icons/Favorite | canosso | Add-ons & Scripts | 26 | 03-02-2010 03:06 AM |
| WW1.3.2-Plugin: Layer Edit | canosso | Add-ons & Scripts | 21 | 02-27-2010 04:37 AM |
| Simple scalebar layer | patmurris | Development Help | 4 | 12-20-2008 07:00 AM |