update clabel function

This commit is contained in:
wyq 2024-07-22 15:05:32 +08:00
parent fc0bf05f44
commit 4de1cef0ac
4 changed files with 12 additions and 4 deletions

View File

@ -924,6 +924,7 @@ public class Plot2D extends AbstractPlot2D {
aX = aX - labSize.width; aX = aX - labSize.width;
break; break;
} }
aX += aLB.getXShift();
aY -= aLB.getYShift(); aY -= aLB.getYShift();
aY -= labSize.height / 3; aY -= labSize.height / 3;
rect.x = (int) aX; rect.x = (int) aX;

View File

@ -21,10 +21,12 @@
<OpenedFiles> <OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_3.py"/> <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\conout_negtive_value.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conoutm_clabel_1.py"/>
</OpenedFiles> </OpenedFiles>
<RecentFiles> <RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_3.py"/> <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\conout_negtive_value.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\conoutm_clabel_1.py"/>
</RecentFiles> </RecentFiles>
</File> </File>
<Font> <Font>

View File

@ -2368,6 +2368,7 @@ class Axes(object):
same as color of the line. same as color of the line.
:param dynamic: (*boolean*) Draw labels dynamic or not. Default is ``True``. :param dynamic: (*boolean*) Draw labels dynamic or not. Default is ``True``.
:param drawshadow: (*boolean*) Draw shadow under labels or not. :param drawshadow: (*boolean*) Draw shadow under labels or not.
:param shadowcolor: (*color*) Shadow color.
:param fieldname: (*string*) The field name used for label. :param fieldname: (*string*) The field name used for label.
:param xoffset: (*int*) X offset of the labels. :param xoffset: (*int*) X offset of the labels.
:param yoffset: (int*) Y offset of the labels. :param yoffset: (int*) Y offset of the labels.
@ -2377,10 +2378,7 @@ class Axes(object):
gc = layer gc = layer
if isinstance(layer, MILayer): if isinstance(layer, MILayer):
gc = layer._layer gc = layer._layer
dynamic = kwargs.pop('dynamic', True)
if gc.getShapeType() != ShapeTypes.POLYLINE:
dynamic = False
drawshadow = kwargs.pop('drawshadow', dynamic)
labelset = gc.getLabelSet() labelset = gc.getLabelSet()
if isinstance(gc, MapLayer): if isinstance(gc, MapLayer):
fieldname = kwargs.pop('fieldname', labelset.getFieldName()) fieldname = kwargs.pop('fieldname', labelset.getFieldName())
@ -2400,6 +2398,13 @@ class Axes(object):
labelset.setColorByLegend(False) labelset.setColorByLegend(False)
color = plotutil.getcolor(color) color = plotutil.getcolor(color)
labelset.setLabelColor(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) labelset.setDrawShadow(drawshadow)
xoffset = kwargs.pop('xoffset', 0) xoffset = kwargs.pop('xoffset', 0)
labelset.setXOffset(xoffset) labelset.setXOffset(xoffset)