Package org.openfaces.renderkit.cssparser

Examples of org.openfaces.renderkit.cssparser.StyleObjectModel


                        if (sectorPulled != null && sectorPulled > 0) {
                            plot.setExplodePercent(index, (double) sectorPulled);
                        }

                        StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                        if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                            StyleBorderModel border = cssSectorModel.getBorder();
                            Color borderColor = border.getColor();
                            if (borderColor != null) {
                                plot.setSectionOutlinePaint(index, borderColor);
                                plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                            }

                            Color sectorModelColor = cssSectorModel.getColor();
                            if (sectorModelColor != null) {
                                plot.setSectionPaint(index, sectorModelColor);
                            }
                        }
                    }
                }
            } else {
                if (dataset == null || dataset.getKeys() == null)
                    continue;

                for (int j = 0; j < dataset.getKeys().size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        if (border.getColor() != null) {
                            plot.setSectionOutlinePaint(index, border.getColor());
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                    }
                    if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                        plot.setSectionPaint(index, cssSectorModel.getColor());
                    }
                }
            }

        }
View Full Code Here


                plot.setLabelGenerator(new DynamicPieGenerator(chartView, labels.getDynamicText()));
            else
                plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
            //TODO: move to style helper
            if (labels != null) {
                StyleObjectModel cssLabelsModel = labels.getStyleObjectModel();
                plot.setLabelFont(CSSUtil.getFont(cssLabelsModel));
                plot.setLabelPaint(cssLabelsModel.getColor());
                plot.setLabelBackgroundPaint(cssLabelsModel.getBackground());
            }
        } else {
            plot.setLabelGenerator(null);
        }
    }
View Full Code Here

                        if (sectorPulled != null && sectorPulled > 0) {
                            plot.setExplodePercent(index, (double) sectorPulled);
                        }

                        StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                        if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                            StyleBorderModel border = cssSectorModel.getBorder();
                            Color borderColor = border.getColor();
                            if (borderColor != null) {
                                plot.setSectionOutlinePaint(index, borderColor);
                                plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                            }

                            Color sectorModelColor = cssSectorModel.getColor();
                            if (sectorModelColor != null) {
                                plot.setSectionPaint(index, sectorModelColor);
                            }
                        }
                    }
                }
            } else {
                if (dataset == null || dataset.getKeys() == null)
                    continue;

                for (int j = 0; j < dataset.getKeys().size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        if (border.getColor() != null) {
                            plot.setSectionOutlinePaint(index, border.getColor());
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                    }
                    if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                        plot.setSectionPaint(index, cssSectorModel.getColor());
                    }
                }
            }

        }
View Full Code Here

                plot.setLabelGenerator(new DynamicPieGenerator(chartView, labels.getDynamicText()));
            else
                plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
            //TODO: move to style helper
            if (labels != null) {
                StyleObjectModel cssLabelsModel = labels.getStyleObjectModel();
                plot.setLabelFont(CSSUtil.getFont(cssLabelsModel));
                plot.setLabelPaint(cssLabelsModel.getColor());
                plot.setLabelBackgroundPaint(cssLabelsModel.getBackground());
            }
        } else {
            plot.setLabelGenerator(null);
        }
    }
View Full Code Here

    protected void setLineStyleObjectProperty(UIComponent component, String propertyName) {
        String value = getPropertyValue(propertyName);
        if (setAsValueExpressionIfPossible(component, propertyName, value))
            return;

        final StyleObjectModel lineStyleCSSModel = CSSUtil.getLineStyleModel(value);
        final LineStyle lineStyle = PropertiesConverter.toLineStyle(lineStyleCSSModel.getBorder());
        component.getAttributes().put(propertyName, lineStyle);
    }
View Full Code Here

        configure(view);
    }

    private TextTitle getSeriesTitle(Chart chart) {
        StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel();
        TextTitle seriesTitle;
        Font f = CSSUtil.getFont(cssChartViewModel);
        if (f != null) {
            seriesTitle = new TextTitle("Series Title", f);
        } else {
            seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12));
        }

        if (cssChartViewModel.getColor() != null) {
            seriesTitle.setPaint(cssChartViewModel.getColor());
        }
        seriesTitle.setPosition(RectangleEdge.BOTTOM);
        return seriesTitle;
    }
View Full Code Here

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        GraphicText graphicText = (GraphicText) component;

        // default style properties
        StyleObjectModel styleModel = graphicText.getStyleObjectModel();
        StyleFontModel font = styleModel.getFont();
        String fontName = font.getName();
        int fontSize = font.getSize();
        int fontStyle = font.getStyle();

        String text = Rendering.convertToString(context, graphicText, graphicText.getValue());

        int direction = graphicText.getDirection();

        AffineTransform transform = new AffineTransform();

        float translationIndex = (float) 1.2;
        float increaseIndex = (float) 2.4;

        if (text.length() <= 3) {
            translationIndex = 5;
            increaseIndex = 10;
        }

        transform.rotate(Math.toRadians(-direction));

        FontRenderContext frc = new FontRenderContext(transform, true, true);
        TextLayout textLayout = new TextLayout(text, new Font(fontName, fontStyle, fontSize), frc);

        Rectangle bounds = textLayout.getOutline(transform).getBounds();

        // calculate transformed text width and height
        double textHeight = bounds.getSize().getHeight();
        double textWidth = bounds.getSize().getWidth();

        BufferedImage image = new BufferedImage(
                (int) Math.round(textWidth * increaseIndex),
                (int) Math.round(textHeight * increaseIndex),
                BufferedImage.TYPE_INT_ARGB);

        Graphics2D graphics = (Graphics2D) image.getGraphics();
        graphics.setColor(styleModel.getColor());
        graphics.translate(translationIndex * textWidth, translationIndex * textHeight);
        graphics.transform(transform);

        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
View Full Code Here

TOP

Related Classes of org.openfaces.renderkit.cssparser.StyleObjectModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.