Search in sources :

Example 1 with GraphBuilder

use of org.talend.dq.indicators.graph.GraphBuilder in project tdq-studio-se by Talend.

the class MyFirstMain method main.

/**
 * DOC scorreia Comment method "main".
 *
 * @param args
 */
public static void main(String[] args) {
    final MyFirstMain myFirstMain = new MyFirstMain();
    myFirstMain.setAllData(createListObjects());
    myFirstMain.run(new GraphBuilder());
}
Also used : GraphBuilder(org.talend.dq.indicators.graph.GraphBuilder)

Example 2 with GraphBuilder

use of org.talend.dq.indicators.graph.GraphBuilder in project tdq-studio-se by Talend.

the class MyFullDemoMain method startFunction.

public JPanel startFunction() {
    final GraphBuilder graphBuilder = new GraphBuilder();
    // getGraph();
    Graph g = graphBuilder.createMultiGraph(MyFirstMain.createListObjects());
    // init variables
    edge_weight = graphBuilder.getEdgeWeight();
    vertexWeights = graphBuilder.getVertexWeight();
    final GraphRenderer graphRenderer = new GraphRenderer();
    // pr = graphRenderer.createPluggableRenderer();
    pr = new PluggableRenderer();
    Layout layout = new FRLayout(g);
    vv = new VisualizationViewer(layout, pr);
    // add Shape based pick support
    vv.setPickSupport(new ShapePickSupport());
    PickedState picked_state = vv.getPickedState();
    affineTransformer = vv.getLayoutTransformer();
    // create decorators
    vcf = new SeedColor(picked_state);
    ewcs = new EdgeWeightStrokeFunction(edge_weight);
    vsh = new VertexStrokeHighlight(picked_state);
    ff = new FontHandler();
    vs_none = new ConstantVertexStringer(null);
    es_none = new ConstantEdgeStringer(null);
    vssa = new VertexShapeSizeAspect(vertexWeights);
    show_edge = new DirectionDisplayPredicate(true, true);
    show_arrow = new DirectionDisplayPredicate(true, false);
    show_vertex = new VertexDisplayPredicate(false);
    // uses a gradient edge if unpicked, otherwise uses picked selection
    edgePaint = new GradientPickedEdgePaintFunction(new PickableEdgePaintFunction(picked_state, Color.black, Color.cyan), vv, vv, picked_state);
    pr.setVertexPaintFunction(vcf);
    pr.setVertexStrokeFunction(vsh);
    pr.setVertexStringer(vs_none);
    pr.setVertexFontFunction(ff);
    pr.setVertexShapeFunction(vssa);
    pr.setVertexIncludePredicate(show_vertex);
    pr.setEdgePaintFunction(edgePaint);
    pr.setEdgeStringer(es_none);
    pr.setEdgeFontFunction(ff);
    pr.setEdgeStrokeFunction(ewcs);
    pr.setEdgeIncludePredicate(show_edge);
    pr.setEdgeShapeFunction(new EdgeShape.Line());
    pr.setEdgeArrowPredicate(show_arrow);
    JPanel jp = new JPanel();
    jp.setLayout(new BorderLayout());
    vv.setBackground(Color.white);
    GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv);
    jp.add(scrollPane);
    gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);
    gm.add(new PopupGraphMousePlugin());
    addBottomControls(jp);
    vssa.setScaling(true);
    vv.setToolTipFunction(new VoltageTips());
    vv.setToolTipText("<html><center>Use the mouse wheel to zoom<p>Click and Drag the mouse to pan<p>Shift-click and Drag to Rotate</center></html>");
    return jp;
}
Also used : JPanel(javax.swing.JPanel) ConstantEdgeStringer(edu.uci.ics.jung.graph.decorators.ConstantEdgeStringer) PickableEdgePaintFunction(edu.uci.ics.jung.graph.decorators.PickableEdgePaintFunction) FRLayout(edu.uci.ics.jung.visualization.FRLayout) GradientPickedEdgePaintFunction(org.talend.dq.indicators.graph.GradientPickedEdgePaintFunction) FontHandler(org.talend.dq.indicators.graph.FontHandler) BorderLayout(java.awt.BorderLayout) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) GraphBuilder(org.talend.dq.indicators.graph.GraphBuilder) ShapePickSupport(edu.uci.ics.jung.visualization.ShapePickSupport) DirectionDisplayPredicate(org.talend.dq.indicators.graph.DirectionDisplayPredicate) EdgeShape(edu.uci.ics.jung.graph.decorators.EdgeShape) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) EdgeWeightStrokeFunction(org.talend.dq.indicators.graph.EdgeWeightStrokeFunction) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) ConstantVertexStringer(edu.uci.ics.jung.graph.decorators.ConstantVertexStringer) VertexDisplayPredicate(org.talend.dq.indicators.graph.VertexDisplayPredicate) GraphRenderer(org.talend.dq.indicators.graph.GraphRenderer) Layout(edu.uci.ics.jung.visualization.Layout) FRLayout(edu.uci.ics.jung.visualization.FRLayout) BorderLayout(java.awt.BorderLayout) GridLayout(java.awt.GridLayout) AbstractPopupGraphMousePlugin(edu.uci.ics.jung.visualization.control.AbstractPopupGraphMousePlugin) PluggableRenderer(edu.uci.ics.jung.visualization.PluggableRenderer) PickedState(edu.uci.ics.jung.visualization.PickedState) VertexShapeSizeAspect(org.talend.dq.indicators.graph.VertexShapeSizeAspect) VertexStrokeHighlight(org.talend.dq.indicators.graph.VertexStrokeHighlight)

Example 3 with GraphBuilder

use of org.talend.dq.indicators.graph.GraphBuilder in project tdq-studio-se by Talend.

the class CorrelationAnalysisDetailsPage method createPreviewCharts.

public void createPreviewCharts(final ScrolledForm form, final Composite composite, final boolean isCreate) {
    List<Composite> previewChartList = new ArrayList<Composite>();
    if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
        GraphBuilder gBuilder = new GraphBuilder();
        gBuilder.setTotalWeight(columnSetMultiIndicator.getCount());
        List<Object[]> listRows = columnSetMultiIndicator.getListRows();
        // MOD msjian TDQ-4781 2012-6-8: make sure exist data
        if (listRows != null && listRows.size() > 0) {
            // TDQ-4781~
            JungGraphGenerator generator = new JungGraphGenerator(gBuilder, listRows);
            // MOD yyi 2009-09-09 feature 8834
            generator.generate(composite, false, true);
        }
    } else {
        List<ModelElement> numericOrDateList = new ArrayList<ModelElement>();
        if (ColumnsetPackage.eINSTANCE.getCountAvgNullIndicator() == columnSetMultiIndicator.eClass()) {
            numericOrDateList = columnSetMultiIndicator.getNumericColumns();
        }
        if (ColumnsetPackage.eINSTANCE.getMinMaxDateIndicator() == columnSetMultiIndicator.eClass()) {
            numericOrDateList = columnSetMultiIndicator.getDateColumns();
        }
        for (ModelElement column : numericOrDateList) {
            final MetadataColumn tdColumn = (MetadataColumn) column;
            ExpandableComposite exComp = toolkit.createExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
            // $NON-NLS-1$
            exComp.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.column", tdColumn.getName()));
            exComp.setLayout(new GridLayout());
            exComp.setData(columnSetMultiIndicator);
            previewChartList.add(exComp);
            final Composite comp = toolkit.createComposite(exComp);
            comp.setLayout(new GridLayout());
            comp.setLayoutData(new GridData(GridData.FILL_BOTH));
            if (tdColumn != null) {
                IRunnableWithProgress rwp = new IRunnableWithProgress() {

                    public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        monitor.beginTask(// $NON-NLS-1$
                        DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "ColumnMasterDetailsPage.createPreview", tdColumn.getName()), IProgressMonitor.UNKNOWN);
                        Display.getDefault().asyncExec(new Runnable() {

                            public void run() {
                                new HideSeriesChartComposite(comp, getCurrentModelElement(), columnSetMultiIndicator, tdColumn, false);
                            }
                        });
                        monitor.done();
                    }
                };
                try {
                    new ProgressMonitorDialog(getSite().getShell()).run(true, false, rwp);
                } catch (Exception ex) {
                    log.error(ex, ex);
                }
            }
            exComp.addExpansionListener(new ExpansionAdapter() {

                @Override
                public void expansionStateChanged(ExpansionEvent e) {
                    getChartComposite().layout();
                    form.reflow(true);
                }
            });
            exComp.setExpanded(true);
            exComp.setClient(comp);
        }
    }
    if (!previewChartList.isEmpty()) {
        this.previewChartCompsites = previewChartList.toArray(new Composite[previewChartList.size()]);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HideSeriesChartComposite(org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite) HideSeriesChartComposite(org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) DataprofilerCoreException(org.talend.dataquality.exception.DataprofilerCoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JungGraphGenerator(org.talend.dataprofiler.core.ui.chart.jung.JungGraphGenerator) GridData(org.eclipse.swt.layout.GridData) GraphBuilder(org.talend.dq.indicators.graph.GraphBuilder) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 4 with GraphBuilder

use of org.talend.dq.indicators.graph.GraphBuilder in project tdq-studio-se by Talend.

the class CorrelationAnalysisResultPage method createGraphicsSectionPart.

protected Section createGraphicsSectionPart(Composite parentComp) {
    Section section = createSection(// $NON-NLS-1$
    form, // $NON-NLS-1$
    parentComp, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.graphics"), // $NON-NLS-1$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.space"));
    section.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(sectionClient);
    chartComposite = toolkit.createComposite(sectionClient);
    chartComposite.setLayout(new GridLayout());
    if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
        GridData gd = new GridData();
        gd.widthHint = 900;
        gd.heightHint = 450;
        chartComposite.setLayoutData(gd);
        GraphBuilder gBuilder = new GraphBuilder();
        gBuilder.setTotalWeight(columnSetMultiIndicator.getCount());
        List<Object[]> listRows = columnSetMultiIndicator.getListRows();
        // MOD msjian TDQ-4781 2012-6-8: make sure exist data
        if (listRows != null && listRows.size() > 0) {
            JungGraphGenerator generator = new JungGraphGenerator(gBuilder, listRows);
            // MOD yyi 2009-09-09 feature 8834
            generator.generate(chartComposite, false, false);
        }
    // TDQ-4781~
    } else {
        createBubbleOrGanttChart(form, chartComposite, columnSetMultiIndicator);
    }
    section.setClient(sectionClient);
    return section;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HideSeriesChartComposite(org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite) JungGraphGenerator(org.talend.dataprofiler.core.ui.chart.jung.JungGraphGenerator) GridData(org.eclipse.swt.layout.GridData) GraphBuilder(org.talend.dq.indicators.graph.GraphBuilder) Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

GraphBuilder (org.talend.dq.indicators.graph.GraphBuilder)4 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 JungGraphGenerator (org.talend.dataprofiler.core.ui.chart.jung.JungGraphGenerator)2 HideSeriesChartComposite (org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite)2 ConstantEdgeStringer (edu.uci.ics.jung.graph.decorators.ConstantEdgeStringer)1 ConstantVertexStringer (edu.uci.ics.jung.graph.decorators.ConstantVertexStringer)1 EdgeShape (edu.uci.ics.jung.graph.decorators.EdgeShape)1 PickableEdgePaintFunction (edu.uci.ics.jung.graph.decorators.PickableEdgePaintFunction)1 FRLayout (edu.uci.ics.jung.visualization.FRLayout)1 GraphZoomScrollPane (edu.uci.ics.jung.visualization.GraphZoomScrollPane)1 Layout (edu.uci.ics.jung.visualization.Layout)1 PickedState (edu.uci.ics.jung.visualization.PickedState)1 PluggableRenderer (edu.uci.ics.jung.visualization.PluggableRenderer)1 ShapePickSupport (edu.uci.ics.jung.visualization.ShapePickSupport)1 VisualizationViewer (edu.uci.ics.jung.visualization.VisualizationViewer)1 AbstractPopupGraphMousePlugin (edu.uci.ics.jung.visualization.control.AbstractPopupGraphMousePlugin)1 DefaultModalGraphMouse (edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse)1