com.supermap.mapping
类 LabelMatrix
- java.lang.Object
-
- com.supermap.data.InternalHandle
-
- com.supermap.data.InternalHandleDisposable
-
- com.supermap.mapping.LabelMatrix
-
- 所有已实现的接口:
- IDisposable
public class LabelMatrix extends com.supermap.data.InternalHandleDisposable
矩阵标签类。通过该类可以制作出复杂的标签来标注对象。该类可以包含 n*n 个矩阵标签元素,矩阵标签元素的类型可以是图片,符号,标签专题图等。目前支持的矩阵标签元素类型为 LabelMatrixImageCell,LabelMatrixSymbolCell,ThemeLabel,传入其他类型将会抛出异常。 不支持矩阵标签元素中包含矩阵标签,矩阵标签元素不支持含有特殊符号的表达式,不支持沿线标注。
- 示范代码:
- 以下代码示范了如何通过
LabelMatrix
类制作复杂的标签来标注对象。假设名为 World 的数据源中的名为 World 的数据集中,有一个 Path 字段存储了各个国家的国旗图片的全路径,Symbol 字段存储了制作专题图的符号 ID 号。
public void labelMatrixTest() { //返回用于制作矩阵标签专题图的数据集 Workspace workspace = new Workspace(); DatasourceConnectionInfo datasourceConnectInfo = new DatasourceConnectionInfo("G:/SampleData/World/World.udb", "world", ""); Datasource targetDatasource = workspace.getDatasources().open( datasourceConnectInfo); DatasetVector dataset = (DatasetVector) targetDatasource.getDatasets(). get("world"); // 实例化一个两行两列的 LabelMatrix 对象 LabelMatrix labelMatrix = new LabelMatrix(2, 2); //第一行第一个单元格显示国旗,为图片类型的标签元素 LabelMatrixImageCell labelMatrixImageCell = new LabelMatrixImageCell(); labelMatrixImageCell.setPathField("Path"); labelMatrixImageCell.setSizeFixed(false); labelMatrixImageCell.setHeight(5); labelMatrixImageCell.setWidth(5); labelMatrix.set(0, 0, labelMatrixImageCell); //第一行第二个单元格显示国家的名称 ThemeLabel themeLabelCellCountry = new ThemeLabel(); themeLabelCellCountry.setLabelExpression("Country"); labelMatrix.set(1, 0, themeLabelCellCountry); //第二行第一个单元格显示符号,为符号类型的标签元素 LabelMatrixSymbolCell labelMatrixSymbolCell = new LabelMatrixSymbolCell(); labelMatrixSymbolCell.setSymbolIDField("Symbol"); //设置所显示的符号的风格 GeoStyle geostyleSymbol = new GeoStyle(); geostyleSymbol.setMarkerSize(new Size2D(6, 6)); geostyleSymbol.setLineColor(java.awt.Color.getHSBColor(216, 144, 0)); labelMatrixSymbolCell.setStyle(geostyleSymbol); labelMatrix.set(0, 1, labelMatrixSymbolCell); //第二行的第二个单元格显示国家的首都名称 ThemeLabel themeLabelCellCapital = new ThemeLabel(); themeLabelCellCapital.setLabelExpression("Capital"); labelMatrix.set(1, 1, themeLabelCellCapital); //设置标签专题图中的标签矩阵 ThemeLabel themeLabelMatrix = new ThemeLabel(); themeLabelMatrix.setLabels(labelMatrix); // 构造一个新的地图对象,并将该地图对象关联到指定的工作空间 Map map = new Map(workspace); // 将制作的复杂标签专题图作为图层添加到地图中 map.getLayers().add(dataset, themeLabelMatrix, true); // 释放资源 workspace.dispose(); }
-
-
构造器概要
构造器 构造器和说明 LabelMatrix()
构造一个矩阵标签类的新对象。LabelMatrix(int columnCount, int rowCount)
根据给定的矩阵标签的行列数,构造一个矩阵标签类的新对象。LabelMatrix(LabelMatrix labelMatrix)
根据给定的矩阵标签类对象,构造一个与其完全相同的新对象。
-
方法概要
所有方法 实例方法 具体方法 限定符和类型 方法和说明 void
dispose()
释放该对象所占用的资源。Object
get(int column, int row)
返回指定索引处(指定行列号处)所对应的对象。int
getColumnCount()
返回矩阵标签的总列数。int
getRowCount()
返回矩阵标签的总行数。void
set(int column, int row, Object value)
设置指定行列位置处所对应的对象。void
setSize(int columnCount, int rowCount)
重新设置矩阵标签的大小,即矩阵标签的行列数。
-
-
-
构造器详细资料
-
LabelMatrix
public LabelMatrix()
构造一个矩阵标签类的新对象。
-
LabelMatrix
public LabelMatrix(int columnCount, int rowCount)
根据给定的矩阵标签的行列数,构造一个矩阵标签类的新对象。- 参数:
columnCount
- 给定的列数。rowCount
- 给定的行数。
-
LabelMatrix
public LabelMatrix(LabelMatrix labelMatrix)
根据给定的矩阵标签类对象,构造一个与其完全相同的新对象。- 参数:
labelMatrix
- 给定的矩阵标签类对象。
-
-
方法详细资料
-
setSize
public void setSize(int columnCount, int rowCount)
重新设置矩阵标签的大小,即矩阵标签的行列数。- 参数:
columnCount
- 给定的列数。rowCount
- 给定的行数。
-
getColumnCount
public int getColumnCount()
返回矩阵标签的总列数。- 返回:
- 矩阵标签的总列数。
- 默认值:
- 默认值为 0。
-
getRowCount
public int getRowCount()
返回矩阵标签的总行数。- 返回:
- 矩阵标签的总行数。
- 默认值:
- 默认值为 0。
-
get
public Object get(int column, int row)
返回指定索引处(指定行列号处)所对应的对象。矩阵标签元素的类型可以是图片(LabelMatrixImageCell),符号(LabelMatrixSymbolCell),标签专题图(ThemeLabel)。
- 参数:
column
- 指定的列数。row
- 指定的行数。- 返回:
- 指定行列位置处所对应的对象。
-
set
public void set(int column, int row, Object value)
设置指定行列位置处所对应的对象。- 参数:
column
- 指定的列数。row
- 指定的行数。object
- 指定行列位置处所对应的对象。
-
dispose
public void dispose()
释放该对象所占用的资源。当调用该方法之后,此对象不再可用。
-
-
Copyright © 2021–2024 SuperMap. All rights reserved.