首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使芯片可在wafermap jfree图表(javafx应用程序)中的鼠标点击事件中选择

使芯片可在wafermap jfree图表(javafx应用程序)中的鼠标点击事件中选择
EN

Stack Overflow用户
提问于 2017-02-01 04:31:10
回答 1查看 223关注 0票数 0

我已经创建了wafermap图表。我想使晶圆中的芯片(模具)在鼠标点击时可选,并插入标签以及从一个芯片到另一个芯片的线。有人精通jfree图表吗?

wafermap chart

EN

回答 1

Stack Overflow用户

发布于 2017-06-30 00:35:18

以下是晶片贴图的工具提示侦听器的基本部分,这是选择骰子的一种形式。将以下内容添加到WaferMapPlot:

代码语言:javascript
运行
复制
public String findChipAtPoint(double x, double y, Rectangle2D plotArea){
    double[] xValues = this.getChipXValues(plotArea, dataset.getMaxChipX()
         + 2, dataset.getChipSpace());
    double startX = xValues[1];
    double chipWidth = xValues[0];
    int ychips = this.dataset.getMaxChipY()+ 2;
    double[] yValues = this.getChipYValues(plotArea, ychips, 
         dataset.getChipSpace());
    double startY = yValues[1];
    double chipHeight = yValues[0];
    double chipSpace = dataset.getChipSpace();
    int chipX = (int)Math.floor((x - startX + chipWidth + chipSpace) / 
        (chipWidth + chipSpace));
    int chipY = (int)Math.floor((y - startY + chipHeight + chipSpace) / 
         (chipHeight + chipSpace));
    chipX = chipX - dataset.getXOffset() - 1;
    chipY = ychips - chipY - dataset.getYOffset() - 1;
    StringBuilder sb = new StringBuilder("(");
    Number value = dataset.getChipValue(chipX, chipY);
    if (value instanceof Double)
        value = value.intValue();
    sb.append(chipX).append(",").append(chipY).append(") ").append(
       (value == null) ? "" : value.toString());
    return sb.toString();
}

然后创建ChartPanel的一个子类,它将成为侦听器:

代码语言:javascript
运行
复制
public class WaferMapChartPanel extends ChartPanel {

WaferMapPlot waferPlot = null;
WaferMapDataset dataSet = null;

public WaferMapChartPanel(JFreeChart chart){
    super(chart);
    waferPlot = (WaferMapPlot)chart.getPlot();
    if (waferPlot != null)
        dataSet = waferPlot.getDataset();
}

 /**
 * Returns a string for the tooltip.
 * @param e  the mouse event.
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
@Override
public String getToolTipText(MouseEvent e) {
   if (waferPlot != null){
        Object source = e.getSource();
        if (source instanceof WaferMapChartPanel){
            WaferMapChartPanel chartSource= (WaferMapChartPanel)e.getSource();
            Rectangle2D plotArea = chartSource.getChartRenderingInfo().getPlotInfo().getPlotArea();
            Insets insets = this.getInsets();
            double x = (e.getX() - insets.left) / this.getScaleX();
            double y = (e.getY() - insets.top) / this.getScaleY();
            return waferPlot.findChipAtPoint(x, y, plotArea);
        }
    }
    return "";
}
}

这将创建骰子的x、y和bin的工具提示,或者您正在使用的任何值而不是bin。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41966946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档