Menu

Web WaferMap Chart

Help
james
2011-08-10
2013-01-13
<< < 1 2 (Page 2 of 2)
  • james

    james - 2011-09-14

    Just downloaded the latest source codes. Thanks. :-)

     
  • james

    james - 2011-09-16

    Hi,

    I have made a few minor changes that would additionally improve the wafer map chart generation and that would allow users to define layout specifics.

    Please let me know if these changes could be made or if you have any questions/suggestions. Thank you in advance! :-)

    1.) I modified the de.laures.cewolf.cpp.TitleEnhancer.java (starting from line 155) to allow creation of multiple subtitles. I made the change because right now based on my testing, only one subtitle is allowed to be generated for a each specific chart. (Please correct me if I'm wrong)

    if (title != null || "title".equals(type)) {
    // Commented to allow creation of multiple subtitles
    //if (title.length()==0 || "title".equals(type)) {
        TextTitle tt = null;
        if ("subtitle".equals(type)) {
            // search for subtitle
            List subTitles = localChart.getSubtitles();
            Iterator iter = subTitles.iterator();
            while (iter.hasNext()) {
                Object o = iter.next();
                if (o instanceof TextTitle) {
                    tt = (TextTitle) o;
                    break;
                }
            }
            // Commented to allow creation of multiple subtitles
            //if (tt == null) {
                tt = new TextTitle(title);
                localChart.addSubtitle(tt);
            //}
        } else {
            tt = localChart.getTitle();
            if (tt == null) {
                tt = new TextTitle(title);
                localChart.setTitle(tt);
            }
        }

        Font font = new Font(fontName,
                            (isBold ? Font.BOLD : 0) + (isItalic ? Font.ITALIC : 0),
                            fontSize);
        tt.setFont(font);
        if (paint != null)
            tt.setPaint(paint);
        if (backgroundPaint != null)
            tt.setBackgroundPaint(backgroundPaint);
        if (tAlign != null)
            tt.setTextAlignment(tAlign);
        if (hAlign != null)
            tt.setHorizontalAlignment(hAlign);
        if (position != null)
            tt.setPosition(position);
    }
           
           
    2.)  I modified the de.laures.cewolf.cpp.WaferMapLegendProcessor.java to allow the legend.setVerticalAlignment() to be set from the JSP.

    public class WaferMapLegendProcessor implements ChartPostProcessor, Serializable {
    static final long serialVersionUID = -1915129061254557435L;

    public void processChart (Object chart, Map params) {
    JFreeChart localChart = (JFreeChart) chart;
    Plot plot = (Plot) localChart.getPlot();
    if (plot instanceof WaferMapPlot) {

    // whether or not to show grid values
    String str = (String) params.get("showCellValues");
    if (str != null) {
                    ((WaferMapPlot) plot).setShowCellValues("true".equals(str));
                }

                // Manage the legend's vertical alignment
                VerticalAlignment vAlign = null;
                String vAlignParam = (String) params.get("valign");
                if (vAlignParam != null) {
                    if ("top".equalsIgnoreCase(vAlignParam)) {
                        vAlign = VerticalAlignment.TOP;
                    } else if ("center".equalsIgnoreCase(vAlignParam)) {
                        vAlign = VerticalAlignment.CENTER;
                    } else if ("bottom".equalsIgnoreCase(vAlignParam)) {
                        vAlign = VerticalAlignment.BOTTOM;
                    }
                }

    final LegendItemCollection legendItemCollection = new LegendItemCollection();
    if (params.size() > 0) {
    String colorStr = null;
    String legendDesc = null;
    Iterator iterator = params.keySet().iterator();
    while (iterator.hasNext()) {
    colorStr = (String) iterator.next();
    if (colorStr.startsWith("#")) {
    legendDesc = (String) params.get(colorStr);
    legendItemCollection.add(new LegendItem(legendDesc, Color.decode(colorStr)));
    }
    }
    }

    LegendTitle legend = localChart.getLegend();
                // Set the legend's vertical alignment.
                if (vAlign != null) {
                    legend.setVerticalAlignment(vAlign);
                }

    if (legend != null) {
    legend.setSources(new LegendItemSource {
    new LegendItemSource() {
    public LegendItemCollection getLegendItems() {
    return legendItemCollection;
    }
    }
    });
    }
    }
    }
       
    3.) Lastly, i added a verification to de.laures.cewolf.jfree.WaferMapPlot.java (drawChipGrid() method, line 321) that would correct the display of wafer map cell values when the value is greater than 9 (2 digits).

    protected void drawChipGrid(Graphics2D g2, Rectangle2D plotArea) {

        Shape savedClip = g2.getClip();
        g2.setClip(getWaferEdge(plotArea));
        Rectangle2D chip = new Rectangle2D.Double();
        int xchips = 35;
        int ychips = 20;
        double space = 1d;
        if (this.dataset != null) {
            xchips = this.dataset.getMaxChipX() + 2;
            ychips = this.dataset.getMaxChipY() + 2;
            space = this.dataset.getChipSpace();
        }
        double startX = plotArea.getX();
        double startY = plotArea.getY();
        double chipWidth = 1d;
        double chipHeight = 1d;
        if (plotArea.getWidth() != plotArea.getHeight()) {
            double major = 0d;
            double minor = 0d;
            if (plotArea.getWidth() > plotArea.getHeight()) {
                major = plotArea.getWidth();
                minor = plotArea.getHeight();
            } else {
                major = plotArea.getHeight();
                minor = plotArea.getWidth();
            }
            //set upperLeft point
            if (plotArea.getWidth() == minor) { // x is minor
                startY += (major - minor) / 2;
                chipWidth = (plotArea.getWidth() - (space * xchips - 1)) / xchips;
                chipHeight = (plotArea.getWidth() - (space * ychips - 1)) / ychips;
            } else { // y is minor
                startX += (major - minor) / 2;
                chipWidth = (plotArea.getHeight() - (space * xchips - 1)) / xchips;
                chipHeight = (plotArea.getHeight() - (space * ychips - 1)) / ychips;
            }
        }

        for (int x = 1; x <= xchips; x++) {
            double upperLeftX = (startX - chipWidth) + (chipWidth * x) + (space * (x - 1));
            for (int y = 1; y <= ychips; y++) {
                double upperLeftY = (startY - chipHeight) + (chipHeight * y) + (space * (y - 1));
                chip.setFrame(upperLeftX, upperLeftY, chipWidth, chipHeight);
                g2.setColor(Color.white);
                if (this.dataset.getChipValue(x - 1, ychips - y - 1) != null) {
                    g2.setPaint( this.renderer.getChipColor( this.dataset.getChipValue(x - 1, ychips - y - 1)));
                }
                g2.fill(chip);
                g2.setColor(Color.lightGray);
                g2.draw(chip);
                if (showCellValues) {
                    String chipValueString = " ";
                    Number chipValue = this.dataset.getChipValue(x - 1, ychips - y - 1);
                    if (chipValue != null) {
                        g2.setPaint(this.renderer.getChipColor(chipValue));
                        chipValueString = String.valueOf(chipValue.intValue());
                        g2.fill(chip);
                        g2.setColor(Color.lightGray);
                        g2.draw(chip);
                        g2.setColor(Color.black);
                        Rectangle2D bounds = chip.getBounds2D();
                        int fontSize = (int) (Math.floor(bounds.getHeight() / 2));
                        Font font = new Font("SansSerif", Font.PLAIN, fontSize);
                        FontRenderContext frc = g2.getFontRenderContext();
                        TextLayout layout = new TextLayout(chipValueString, font, frc);
                        float xPos = (float) (bounds.getMinX() + ((bounds.getMaxX() - bounds.getMinX()) / 3.0f));
                        float yPos = (float) (bounds.getMinY() + ((bounds.getMaxY() - bounds.getMinY()) * 2.0f / 3.0f));

                        // Correct the text alignment if the cell value is greater then 9 (2 digits)
                        if (chipValue.intValue() > 9) {
                            xPos = (float) (bounds.getMinX() + ((bounds.getMaxX() - bounds.getMinX()) * 0.05f));
                        }

                        layout.draw(g2, xPos, yPos);
                    }
                }
            }
        }
        g2.setClip(savedClip);
    }
       

     
  • Ulf Dittmer

    Ulf Dittmer - 2011-09-18

    I just released version 1.1.11 which incorporates these mostly as they are.

     
  • james

    james - 2011-09-19

    This is great! Thank you for implementing the changes. I have tested the features and all works perfectly. Also, thank you for improving the logic! :-)

    I will keep you posted if anything comes up on my side.

    Best regards,
    -James

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.