2017-01-31 8 views
0

私はwafermapチャートを作成しました。私は、マウスのクリックで選択可能なウェハー(ダイ)を作成して、あるチップから別のチップへのラベルラインを挿入したいと考えています。誰でもjfreeチャートのエキスパートですか?ここでチップをwafermap jfree chart(javafxアプリケーション)のマウスクリックイベントで選択可能

wafermap chart

+1

'ChartMouseListener'を追加するとどうなりますか? – trashgod

+1

クロス投稿[ここ](http://www.jfree.org/forum/viewtopic.php?f=3&t=117760); [tag:jfreechart]投稿者は、既存の 'WaferMapRenderer'にエンティティサポートがないことを観察します。 – trashgod

+0

@trashgodどのようにすべてのチップにマウスのリスナーを追加できますか?少なくとも私にラベルやチップの色の変化を与えてくれるでしょうか? –

答えて

0

ダイを選択する形式であるウエハマップのツールチップリスナーのための基本的な部分があります。 WaferMapPlotに以下を追加:これはあなたを使用しているダイのx、y、およびビンまたはどのような値のツールチップを作成し

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 ""; 
} 
} 

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のサブクラスを作りますビンの代わりに。

関連する問題