layer.set LegendLabel()

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

layer.set LegendLabel()

Post by hproe »

Hi -

According to the User's Guide one can create a layer label with setLayerLabel(keywords).

I would expect that you could create also legend label, extra legend labels and ID in a similar way. Although I could not find it in the Jython library, I have tried setLegendLabel(keywords). It returns an error message saying that setLegendLabels() takes no keywords.

Am I missing something or are these feature missing?

HP
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: layer.set LegendLabel()

Post by jayh »

Hi HP-

These features are missing, and the only implementation we have of functions like this are setLayerLabel().

I've created inq. 2133 for this enhancement to be evaluated.

Thanks, Jay
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: layer.set LegendLabel()

Post by bobc »

Hi HP -

While there's no one function to set the legend label, extra legend label, and display ID like there is with the layer label (as the inquiry mentions), there is a workaround that requires a couple functions to set each of them. Here is a script that displays some imagery data then prints out the current legend label, extra legend label, and display ID before changing them and applying the changed labels to the display. You don't need the print lines I have, I just put them in there to verify that things were working.

Code: Select all

# display some imagery data.  data is the output of loadADDEImage
# not included in this script.
satLayer = activeDisplay().createLayer('Image Display',data)

# update legend label
print satLayer.getLegendLabelTemplate()
satLayer.setLegendLabelTemplate('My new legend Label')
print satLayer.getLegendLabelTemplate()
satLayer.updateLegendLabel()

# update extra legend label
print satLayer.getExtraLabelTemplate()
satLayer.setExtraLabelTemplate('My new extra legend label')
print satLayer.getExtraLabelTemplate()
satLayer.updateLegendAndList()

# update display id
print satLayer.getDisplayId()
satLayer.setDisplayId('myNewDisplayId')
print satLayer.getDisplayId()

Please let me know if you have any questions.

Thanks -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: layer.set LegendLabel()

Post by hproe »

Hi Bob -

Thanks for the tricks.

They are working fine for the label and extra label, but it appears I do not have to issue the respective satLayer.update...?
They get displayed straight away.

However, I cannot get the DisplayId to work (not a real problem for me, just for the sake of completeness). Ther box remains void.

HP
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: layer.set LegendLabel()

Post by bobc »

Hi HP -

Instead of using setDisplayId(), can you try setId(). I was able to get this to work by first running your sequence_FD function, then I used setId to set the imagery layer's ID to be 'thisColourBar', and then run writeImageAtIndex with switch=3.

For example:

Code: Select all

sequence_FD('2005-12-01 00:00UTC',5,2)
dispLayer = activeDisplay().getLayer(1)
dispLayer.setId('thisColourBar')
svImageSeq(3,'/HP_Test/switch3/','postFix','preFix',10,1000,800,'Spain')

As for running the update* functions in my previous post, I found that I had to do this to actually get the changed legend label and added extra legend label to show up in the Legend of the Main Display window. However, I don't have to run the update* functions to get them to appear in the Edit>Properties window of the layer. Is this what you are seeing, or are you seeing your updated legend/extra legend labels to appear in the Legend without running the update* functions?

Thanks -
Bob
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: layer.set LegendLabel()

Post by hproe »

Hi Bob -

Code: Select all

dispLayer = activeDisplay().getLayer(1)
dispLayer.setId('thisColourBar')

works well!

Sorry for having not been clear enough about the update functions. I do not have to use them at all. The changed labels appear in the Legend straight away, without having to call them.

So, for me e.g.

Code: Select all

dispLayer = activeDisplay().getLayer(1)
displayLayer.setLegendLabelTemplate(%longname%)
displayLayer.setExtraLabelTemplate(%shortname%)
displayLayer.setLayerLabel(%timestamp%)
dispLayer.setId('thisColourBar')

print legend and layer labels as desired. The wording of the commands is not very consolidated, though.

HP
Post Reply