Skip to content

Commit

Permalink
update clabel function
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaqiang committed Jul 22, 2024
1 parent fc0bf05 commit 4de1cef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ public Rectangle getGraphicRectangle(Graphics2D g, Graphic aGraphic, Rectangle2D
aX = aX - labSize.width;
break;
}
aX += aLB.getXShift();
aY -= aLB.getYShift();
aY -= labSize.height / 3;
rect.x = (int) aX;
Expand Down
2 changes: 2 additions & 0 deletions meteoinfo-lab/milconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_3.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conout_negtive_value.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conoutm_clabel_1.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_3.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conout_negtive_value.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conoutm_clabel_1.py"/>
</RecentFiles>
</File>
<Font>
Expand Down
Binary file modified meteoinfo-lab/pylib/mipylib/plotlib/_axes$py.class
Binary file not shown.
13 changes: 9 additions & 4 deletions meteoinfo-lab/pylib/mipylib/plotlib/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,7 @@ def clabel(self, layer, **kwargs):
same as color of the line.
:param dynamic: (*boolean*) Draw labels dynamic or not. Default is ``True``.
:param drawshadow: (*boolean*) Draw shadow under labels or not.
:param shadowcolor: (*color*) Shadow color.
:param fieldname: (*string*) The field name used for label.
:param xoffset: (*int*) X offset of the labels.
:param yoffset: (int*) Y offset of the labels.
Expand All @@ -2377,10 +2378,7 @@ def clabel(self, layer, **kwargs):
gc = layer
if isinstance(layer, MILayer):
gc = layer._layer
dynamic = kwargs.pop('dynamic', True)
if gc.getShapeType() != ShapeTypes.POLYLINE:
dynamic = False
drawshadow = kwargs.pop('drawshadow', dynamic)

labelset = gc.getLabelSet()
if isinstance(gc, MapLayer):
fieldname = kwargs.pop('fieldname', labelset.getFieldName())
Expand All @@ -2400,6 +2398,13 @@ def clabel(self, layer, **kwargs):
labelset.setColorByLegend(False)
color = plotutil.getcolor(color)
labelset.setLabelColor(color)

dynamic = kwargs.pop('dynamic', gc.getShapeType() == ShapeTypes.POLYLINE)
drawshadow = kwargs.pop('drawshadow', dynamic)
shadowcolor= kwargs.pop('shadowcolor', Color.white if drawshadow else None)
if shadowcolor is not None:
labelset.setShadowColor(plotutil.getcolor(shadowcolor))
drawshadow = True
labelset.setDrawShadow(drawshadow)
xoffset = kwargs.pop('xoffset', 0)
labelset.setXOffset(xoffset)
Expand Down

0 comments on commit 4de1cef

Please sign in to comment.