[437882] Update ACTF examples to support Eclipse 4.x
diff --git a/features/org.eclipse.actf.examples.emine-feature/feature.xml b/features/org.eclipse.actf.examples.emine-feature/feature.xml index 9d2d78e..21c8d88 100644 --- a/features/org.eclipse.actf.examples.emine-feature/feature.xml +++ b/features/org.eclipse.actf.examples.emine-feature/feature.xml
@@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <feature id="org.eclipse.actf.examples.emine" - label="ACTF Example eMINE feature (Incubation)" - version="0.9.2.qualifier" + label="ACTF Example eMINE feature" + version="1.2.0.qualifier" provider-name="Eclipse.org" plugin="org.eclipse.actf.examples.emine" os="win32" @@ -24,14 +24,14 @@ id="org.eclipse.rcp" version="0.0.0"/> - <requires> - <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/> - <import plugin="com.ibm.icu"/> - <import plugin="org.eclipse.swt"/> - <import plugin="org.eclipse.help" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.ui" version="3.3.0" match="compatible"/> - </requires> + <includes + id="org.eclipse.emf.common" + version="0.0.0"/> + <includes + id="org.eclipse.emf.ecore" + version="0.0.0"/> + <plugin id="org.eclipse.actf.core" download-size="0"
diff --git a/features/org.eclipse.actf.examples.simplevisualizer-feature/feature.xml b/features/org.eclipse.actf.examples.simplevisualizer-feature/feature.xml index 16ff03a..fa62574 100644 --- a/features/org.eclipse.actf.examples.simplevisualizer-feature/feature.xml +++ b/features/org.eclipse.actf.examples.simplevisualizer-feature/feature.xml
@@ -1,139 +1,139 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feature - id="org.eclipse.actf.examples.simplevisualizer" - label="ACTF Example Simple Visualizer feature" - version="1.2.0.qualifier" - provider-name="Eclipse.org" - plugin="org.eclipse.actf.examples.simplevisualizer" - os="win32" - ws="win32"> - - <description> - %description - </description> - - <copyright> - %copyright - </copyright> - - <license url="license.html"> - %license - </license> - - <includes - id="org.eclipse.rcp" - version="0.0.0"/> - - <requires> - <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/> - <import plugin="com.ibm.icu"/> - <import plugin="org.eclipse.swt"/> - <import plugin="org.eclipse.help" version="3.2.0" match="compatible"/> - <import plugin="org.eclipse.ui" version="3.3.0" match="compatible"/> - </requires> - - <plugin - id="org.eclipse.actf.core" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.mediator" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.model.dom.dombycom" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.model.dom.html" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.model.ui" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.model.ui.editors.ie" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.ui" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.util.win32.comclutch" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.util.vocab" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.visualization" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.visualization.eval" - download-size="0" - install-size="0" - version="0.0.0"/> - - <plugin - id="org.eclipse.actf.visualization.ui.report" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.ui.views" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.util.win32" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - - <plugin - id="org.eclipse.actf.examples.simplevisualizer" - download-size="0" - install-size="0" - version="0.0.0" - unpack="false"/> - -</feature> +<?xml version="1.0" encoding="UTF-8"?> +<feature + id="org.eclipse.actf.examples.simplevisualizer" + label="ACTF Example Simple Visualizer feature" + version="1.2.0.qualifier" + provider-name="Eclipse.org" + plugin="org.eclipse.actf.examples.simplevisualizer" + os="win32" + ws="win32"> + + <description> + %description + </description> + + <copyright> + %copyright + </copyright> + + <license url="license.html"> + %license + </license> + + <includes + id="org.eclipse.rcp" + version="0.0.0"/> + + <includes + id="org.eclipse.emf.common" + version="0.0.0"/> + + <includes + id="org.eclipse.emf.ecore" + version="0.0.0"/> + + <plugin + id="org.eclipse.actf.core" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.mediator" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.model.dom.dombycom" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.model.dom.html" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.model.ui" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.model.ui.editors.ie" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.ui" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.util.win32.comclutch" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.util.vocab" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.visualization" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.visualization.eval" + download-size="0" + install-size="0" + version="0.0.0"/> + + <plugin + id="org.eclipse.actf.visualization.ui.report" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.ui.views" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.util.win32" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + + <plugin + id="org.eclipse.actf.examples.simplevisualizer" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + +</feature>
diff --git a/plugins/org.eclipse.actf.examples.emine/META-INF/MANIFEST.MF b/plugins/org.eclipse.actf.examples.emine/META-INF/MANIFEST.MF index 8c8c136..8535f57 100644 --- a/plugins/org.eclipse.actf.examples.emine/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.actf.examples.emine/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: ACTF Example eMINE (Incubation) Bundle-SymbolicName: org.eclipse.actf.examples.emine;singleton:=true -Bundle-Version: 0.9.2.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Activator: org.eclipse.actf.examples.emine.EminePlugin Bundle-Vendor: Eclipse.org Bundle-Localization: plugin @@ -17,6 +17,9 @@ org.eclipse.actf.model.ui.editors.ie, org.eclipse.actf.visualization.ui.report, org.eclipse.ui.views, - org.eclipse.actf.util.vocab + org.eclipse.actf.util.vocab, + org.eclipse.e4.ui.model.workbench, + org.eclipse.e4.ui.workbench, + org.eclipse.e4.core.contexts Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.actf.examples.emine/src/org/eclipse/actf/examples/emine/ApplicationWorkbenchWindowAdvisor.java b/plugins/org.eclipse.actf.examples.emine/src/org/eclipse/actf/examples/emine/ApplicationWorkbenchWindowAdvisor.java index dcb8e63..515389e 100644 --- a/plugins/org.eclipse.actf.examples.emine/src/org/eclipse/actf/examples/emine/ApplicationWorkbenchWindowAdvisor.java +++ b/plugins/org.eclipse.actf.examples.emine/src/org/eclipse/actf/examples/emine/ApplicationWorkbenchWindowAdvisor.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 IBM Corporation, Middle East Technical University + * Copyright (c) 2006, 2015 IBM Corporation, Middle East Technical University * Northern Cyprus Campus and Others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,14 +12,18 @@ *******************************************************************************/ package org.eclipse.actf.examples.emine; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuManager; import org.eclipse.ui.IWorkbenchPreferenceConstants; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.application.WorkbenchWindowAdvisor; +import org.eclipse.ui.internal.WorkbenchWindow; public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @@ -59,6 +63,19 @@ items[i].dispose(); } } + + // hide quick access (for Eclipse 4.2.x) + try { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + MWindow model = ((WorkbenchWindow) window).getModel(); + EModelService modelService = model.getContext().get( + EModelService.class); + modelService.find("SearchField", model).setToBeRendered(false); + } catch (Exception e) { + + } + } }
diff --git a/plugins/org.eclipse.actf.examples.emine/vips.product b/plugins/org.eclipse.actf.examples.emine/vips.product index c419188..df9fd40 100644 --- a/plugins/org.eclipse.actf.examples.emine/vips.product +++ b/plugins/org.eclipse.actf.examples.emine/vips.product
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?pde version="3.5"?> -<product name="eMINE VIPS" id="org.eclipse.actf.examples.emine.vips" application="org.eclipse.actf.examples.emine.EmineSampleApplication" version="0.9.2.qualifier" useFeatures="true" includeLaunchers="true"> +<product name="eMINE VIPS" id="org.eclipse.actf.examples.emine.vips" application="org.eclipse.actf.examples.emine.EmineSampleApplication" version="1.2.0.qualifier" useFeatures="true" includeLaunchers="true"> <aboutInfo> <image path="/org.eclipse.actf.examples.emine/about.gif"/> @@ -28,16 +28,14 @@ </win> </launcher> - <vm> </vm> - <plugins> </plugins> <features> - <feature id="org.eclipse.actf.examples.emine" version="0.9.2.qualifier"/> + <feature id="org.eclipse.actf.examples.emine" version="1.2.0.qualifier"/> </features>
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/META-INF/MANIFEST.MF b/plugins/org.eclipse.actf.examples.simplevisualizer/META-INF/MANIFEST.MF index aca8fae..487685f 100644 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.actf.examples.simplevisualizer/META-INF/MANIFEST.MF
@@ -17,6 +17,9 @@ org.eclipse.actf.model.ui.editors.ie, org.eclipse.actf.visualization.ui.report, org.eclipse.ui.views, - org.eclipse.actf.util.vocab + org.eclipse.actf.util.vocab, + org.eclipse.e4.ui.model.workbench, + org.eclipse.e4.ui.workbench, + org.eclipse.e4.core.contexts Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ApplicationWorkbenchWindowAdvisor.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ApplicationWorkbenchWindowAdvisor.java index c365275..d0cee65 100644 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ApplicationWorkbenchWindowAdvisor.java +++ b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ApplicationWorkbenchWindowAdvisor.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and Others + * Copyright (c) 2006, 2015 IBM Corporation and Others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,14 +10,18 @@ *******************************************************************************/ package org.eclipse.actf.examples.simplevisualizer; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuManager; import org.eclipse.ui.IWorkbenchPreferenceConstants; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.application.WorkbenchWindowAdvisor; +import org.eclipse.ui.internal.WorkbenchWindow; public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @@ -57,6 +61,18 @@ items[i].dispose(); } } + + // hide quick access (for Eclipse 4.2.x) + try { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + MWindow model = ((WorkbenchWindow) window).getModel(); + EModelService modelService = model.getContext().get( + EModelService.class); + modelService.find("SearchField", model).setToBeRendered(false); + } catch (Exception e) { + + } } }
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/HTMLPerspective.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/HTMLPerspective.java index 06d1eca..0d22e9f 100644 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/HTMLPerspective.java +++ b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/HTMLPerspective.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and Others + * Copyright (c) 2006, 2015 IBM Corporation and Others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -48,10 +48,10 @@ try { PerspectiveListenerForBrowserLaunch.setTargetUrl(new URL( - "http://www.eclipse.org/actf")); + "https://www.eclipse.org/actf")); } catch (MalformedURLException e) { } - + PlatformUI.getWorkbench().getActiveWorkbenchWindow() .addPerspectiveListener( new PerspectiveListenerForBrowserLaunch(ID));
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/PerspectiveListenerForBrowserLaunch.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/PerspectiveListenerForBrowserLaunch.java deleted file mode 100644 index bc46ff3..0000000 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/ui/perspectives/PerspectiveListenerForBrowserLaunch.java +++ /dev/null
@@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and Others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Kentarou FUKUDA - initial API and implementation - *******************************************************************************/ - -package org.eclipse.actf.examples.simplevisualizer.ui.perspectives; - -import org.eclipse.actf.model.ui.editors.ie.WebBrowserEditor; -import org.eclipse.actf.model.ui.util.ModelServiceUtils; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IPerspectiveListener; -import org.eclipse.ui.IWorkbenchPage; - -public class PerspectiveListenerForBrowserLaunch implements - IPerspectiveListener { - - private String id; - - public PerspectiveListenerForBrowserLaunch(String id) { - this.id = id; - } - - public void perspectiveActivated(IWorkbenchPage page, - IPerspectiveDescriptor perspective) { - if (id.equals(perspective.getId())) { - if (!ModelServiceUtils.activateEditorPart(WebBrowserEditor.ID)) { - ModelServiceUtils - .launch("http://www.eclipse.org/actf", - WebBrowserEditor.ID); - } - } - } - - public void perspectiveChanged(IWorkbenchPage page, - IPerspectiveDescriptor perspective, String changeId) { - } - -}
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Complexity.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Complexity.java deleted file mode 100644 index cb5aadd..0000000 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Complexity.java +++ /dev/null
@@ -1,707 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 University of Manchester and Others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eleni Michailidou - initial API and implementation - *******************************************************************************/ -package org.eclipse.actf.examples.simplevisualizer.vicramtest; - -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.actf.model.dom.dombycom.IElementEx; -import org.eclipse.actf.model.dom.dombycom.INodeEx; -import org.eclipse.actf.model.dom.dombycom.IStyle; -import org.eclipse.actf.model.ui.IModelService; -import org.eclipse.actf.model.ui.editor.browser.ICurrentStyles; -import org.eclipse.actf.model.ui.editor.browser.IWebBrowserACTF; -import org.eclipse.actf.model.ui.editor.browser.IWebBrowserStyleInfo; -import org.eclipse.actf.model.ui.util.ModelServiceUtils; -import org.eclipse.swt.graphics.Rectangle; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class Complexity { - - public static int links, images, tables, paragraphs, forms, linkedWords, - unlinkedWords, listWords, rowWords, colWords, rows, columns, lists, - listItems, wordCount, blocks, TLC; - public static String words; - public static boolean insideLink = false; - public static boolean insideList = false; - public static boolean insideTableRow = false; - public static boolean insideTableCol = false; - public static String linkedString, unlinkedString; - private static int tableStyle; - private static String backgroundColor; - private static String display; - private static String backgroundColorParent; - private static int TLC1; - private static int TLC2; - private static int layoutTable; - private static int div; - private static boolean findName = true; - private static boolean isLayout; - private static int dataTables; - private static boolean isTLC = false; - private static boolean backgroundDif; - private static String backgroundColorGrandParent; - private static boolean blockChild; - private static boolean headingTLC; - private static boolean singlesChildren; - private static boolean lastIsImg; - private static int len; - private static String borderWidth; - private static int borderLen; - private static boolean visibleBorder; - private static boolean isPx; - private static Rectangle rectangle; - private static Map<String, ICurrentStyles> styleMap; - private static Object xpath; - private static boolean veryComplex; - public static double VCS; - - /* - * - * 1. Calculates the level of complexity and aesthetics of Web pages - * Equations: VisualComplexity = 1.743 + 0.097 (TLC) + 0.053 (Words) + 0.003 (Images) - * - * THE FINAL Visual Complexity Score is equal to: VisualComplexity/10. - * If the score is > 10 then VC =10, and denotes extreme complexity due to - * length of page, a lot of text, a large number of images etc. - * - * For more details: - * ViCRAM Webpage: http://vicram.cs.manchester.ac.uk - */ - public static String calculate() { - /* - * calculate method is called from PartControlSimpleVisualizer This - * method calls the appropriate methods that analyze the DOM structure - * of the page, counts the appropriate page elements and based on the - * complexity formula gives the score (VCS) by returning an appropriate - * string - */ - - // initialize modelService and get the style information based on IE - // Current Styles method - IModelService modelService = ModelServiceUtils.getActiveModelService(); - if (modelService instanceof IWebBrowserACTF) { - IWebBrowserACTF browser = (IWebBrowserACTF) modelService; - IWebBrowserStyleInfo style = browser.getStyleInfo(); - // ModelServiceSizeInfo sizeInfo = style.getSizeInfo(true); - - styleMap = style.getCurrentStyles(); - - } - /* - * A. initialize Document based on DOM and LiveDOM in order to identify - * the number of blocks the page has (TLC) the liveDoc will be used. - * LiveDoc returns the style information as it is currently presented by - * the browser - * - * B. if the documents are not empty then get respective - * elements, reset variables used as counters and help counters, - * initialize the body Node and recursively pass the docElement and - * docLiveElement to the countElements(node) and countTLC(node) - * respectively - */ - Document doc = modelService.getDocument(); - Document docLive = modelService.getLiveDocument(); - - if (doc == null || docLive == null) { - return "doc is null"; - } else { - - Element docElement = doc.getDocumentElement(); - Element docLiveElement = docLive.getDocumentElement(); - - // reset variables to zero/false appropriately - VCS = 0; - links = 0; - lists = 0; - images = 0; - wordCount = 0; - blocks = 0; - TLC = 0; - TLC1 = 0; - TLC2 = 0; - tables = 0; - layoutTable = 0; - div = 0; - dataTables = 0; - isTLC = false; - headingTLC = false; - singlesChildren = false; - lastIsImg = false; - visibleBorder = false; - isPx = false; - // Elements Counter - countElements(docElement.getElementsByTagName("body").item(0)); - // Block Counter - Node node = docLiveElement.getElementsByTagName("body").item(0); - NodeList NodeChildren = node.getChildNodes(); - if (NodeChildren != null) { - int len = NodeChildren.getLength(); - for (int i = 0; i < len; i++) { - findName = true; - singlesChildren = false; - isTLC = false; - headingTLC = false; - countTLC(NodeChildren.item(i)); - } - } - /* - * Visual Complexity Score calculation - */ - VCS = (1.743 + 0.097 * (TLC) + 0.053 * (wordCount) + 0.003 * (images)) / 10; - if (VCS > 10) { - veryComplex = true; - } else - veryComplex = false; - - String results = ""; - String resultsA = ""; - String resultsB = ""; - String resultsC = ""; - String resultsD = ""; - if (veryComplex == true) { - VCS = 10.0; - resultsA = "VCS = " + VCS + " **"; - resultsC = "NOTE: **(Two stars) after the VCS, signifies that the page just tested was ranked with a score bigger than 10 which is the maximum of our scale."; - } else { - resultsA = "VCS = " + VCS; - resultsC = ""; - } - resultsB = "The Visual Complexity Score (VCS) ranges from 0 to 10, with 0 being very visually simple and 10 very visually complex. "; - resultsD = "The highlighted green boxes are the identified TLC, which is one of the main complexity factors. For more details please visit the ViCRAM Project Webpages at http://hcw.cs.manchester.ac.uk/research/vicram/"; - results = "======= Web Page Visual Complexity =======\n\n" - + resultsA + "\n\n" + resultsB + "\n\n" + resultsC + "\n" + resultsD; - return results + "\n\n"; - - } - } - - /* - * countElements is a recursive method that performs DOM analysis counts the - * page elements by recursively going through the node using DOM parser some - * counters are not used in the final equation but are used as part of the - * discussion in the report and overall structure of the page - */ - public static void countElements(Node node) { - - if (node == null) - return; - - int type = node.getNodeType(); - - if (type == Node.DOCUMENT_NODE) { - countElements(((Document) node).getDocumentElement()); - } - if (type == Node.ELEMENT_NODE) { - // checks and counts the type of element - String nodeName = node.getNodeName(); - if (nodeName.equalsIgnoreCase("a")) - links++; - if (nodeName.equalsIgnoreCase("p")) - paragraphs++; - if (nodeName.equalsIgnoreCase("img")) - images++; - if (nodeName.equalsIgnoreCase("form")) - forms++; - if (nodeName.equalsIgnoreCase("div")) - div++; - if (nodeName.equalsIgnoreCase("table")) { - tables++; - } - if (nodeName.equalsIgnoreCase("ul") - || nodeName.equalsIgnoreCase("ol")) { - lists++; - insideList = true; - } - if (nodeName.equalsIgnoreCase("li")) { - listItems++; - } - - // recurse through the node to find the rest of the counters - NodeList children = node.getChildNodes(); - if (children != null) { - int len = children.getLength(); - for (int i = 0; i < len; i++) { - countElements(children.item(i)); - } - } - }// ends if (type == Node.ELEMENT_NODE) - // Get the word count - if (type == Node.TEXT_NODE) { - String string = node.getNodeValue(); - words = " " + string; - if (words == null) - wordCount = 0; - else { - StringTokenizer total = new StringTokenizer(words, - "'?!@#$&*/-,:.<>()~;=_|"); - while (total.hasMoreTokens() == true) { - StringTokenizer token = new StringTokenizer(total - .nextToken()); - wordCount += token.countTokens(); - } - } - }// ends if (type == Node.TEXT_NODE) - }// ends countElements - - /* - * CountTLC(node) identifies the number of blocks the page is groupped into - * The method is based on the results from the evaluation described in the - * technical report ADD REPORT The block structure algorithm is based on a - * series of heuristic descibred individually below - * - * boolean isTLC - to avoid TLC recognised within TLCs that are basically - * the same (i.e. tables within tables) - * - * NOTE: The TLCs that the algorithm detects are highlighted - * on the page using the following code: - * //TLC - highlight - * ((INodeEx) node).highlight(); - */ - - public static int countTLC(Node node) { - - if (node == null) - return 0; - - int type = node.getNodeType(); - if (type == Node.DOCUMENT_NODE) { - countTLC(((Document) node).getDocumentElement()); } - - if (type == Node.ELEMENT_NODE) { - - if (node instanceof IElementEx) { - IStyle style = ((IElementEx) node).getStyle(); - display = (String) style.get("display"); - borderWidth = (String) style.get("borderWidth"); - - /* - * STEP 1. <div> elements If the node is a <div> element & has a - * visible border => we flag that the node has a visibleBorder: - * 1. Get border attributes: borderWidth returns medium or Npx - * (N=number) need to check if the borderWidth is a number and is >0 - * - * 2. If border width contains a number of pixels as Npx, - * we use StringTokenizer to get the string that contains the - * string part with the px string in it some elements have - * different px for left/right etc (e.g - borderWidth = medium - * medium 5px) - */ - - if (node.getNodeName().equalsIgnoreCase("div")) { - borderLen = borderWidth.length(); - isPx = borderWidth.contains("px"); - int px = 0; - if (isPx == true) { - StringTokenizer borderToken = new StringTokenizer( - borderWidth, " "); - String pixels = ""; - String borderPx = ""; - while (borderToken.hasMoreTokens() == true) { - String token = borderToken.nextToken(); - if (token.contains("px") == true) { - int tokenLength = token.length(); - borderPx = token.substring(0, tokenLength - 2); - } - } - px = Integer.parseInt(borderPx); - if (px > 0) { - visibleBorder = true; - } else - visibleBorder = false; - } - } - }// ends style info extraction - if (display == null) { - display = ""; - } - - /* - * STEP 2. Node is display=block && has no block children (this step - * is to flag elements such as standaline images) => lastIsImg flag - * 1. Get the NodeList of the current node and find the number of - * children that are type=1 ONLY - * - * 2. If there is only one type 1 - * child, we check if it is an <img> and we flag as true - */ - - NodeList children = node.getChildNodes(); - len = 0; - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - int childType = child.getNodeType(); - if (childType == 1) - len++; - } - - blockChild = false; - lastIsImg = false; - String nodeName = node.getNodeName(); - if (len == 1) { - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeName().equalsIgnoreCase("img")) { - lastIsImg = true; - } - } - }// ends if len==1 - - /* - * STEP 3. blockChild: Determine if the node has only one child - * (singleChildren - method) and if it is displayed as block or table: - * - * 1. Determine if it is a singleChildren (see respective method) - * - * 2. Determine if it is a blockChild, that is displayed as - * a block or table no matter of the output of singleChildren - * - * 3. If display=block && blockChild==false => TLC - * - * 4. else If singleChild==true && isTLC==false => TLC - * - * We need to follow these steps because if the last child is an image - * then it is a TLC BUT then might have multiple TLCs! So, we need to check that the img - * is the ONLY children and that the tag is a series of singles children - * - * NOTE: this needs to be visited only once per node so we use a - * boolean flag findName which needs to be reset to true on the main - * method. - * - * Also, isTLC is used to make sure that a node is only once - * identified as TLC and avoid duplicates - */ - - if (findName == true) { - if (children != null) { - Node childNode = children.item(0); - singleChildren(node, len); - for (int i = 0; i < len; i++) { - // need to check each child's display attribute and - // whether is a singleChildren - // insert a flag - if there is at least one block level - // element child then flag as true - // blockChild are blocks! - childNode = children.item(i); - NodeList childNodeList = childNode.getChildNodes(); - int length = childNodeList.getLength(); - singleChildren(node, len); - if (childNode instanceof IElementEx) { - IStyle childStyle = ((IElementEx) childNode) - .getStyle(); - String displayChild = (String) childStyle - .get("display"); - if (displayChild.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table")) - blockChild = true; - } - }// end for-loop - }// end if not null children - - if (display.equalsIgnoreCase("block") && blockChild == false) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - - else if (singlesChildren == true && isTLC == false) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - findName = false; - }// ends if findName == true - - /* - * STEP 4. <div> element and a visible border => TLC We run this - * step here and not earlier to avoid duplicates. A <div> with - * visible border could contain an img as a singleChildren or is - * displayed as block element (see Step 3) - */ - else if (nodeName.equalsIgnoreCase("div")) { - if (visibleBorder == true) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - }// ends if <div> and visible border - - /* - * STEP 5. - * If a block displayed element has block-displayed children - * THis step leads to a set of substeps described where appropriate (5a-5c). - * - * Step 5 is also recursive for some substeps (5c and 5c): - * - * (i). Node is displayed as block/table or display starts with table - * - * (ii). If the node is a <div> element, has visible border and is - * not used for Layout => TLC - * - * (iii). else if the node is a heading <h1> or <h2> => TLC && flag that - * is identified as heading - * - * (iv). else if <h3> && headingTLC==false => TLC - * - * (v). else if <h4> && headintTLC==false => TLC - * - * (vi). else if the node is a table and has visible border need to - * make sure if the table is used for data or layout if the table has a - * caption or a theading => then it would be a data table which - * we count as one TLC if the table has only visible border for now - * we count it as a TLC TLC++ if (one of those else if statements): - * a. dataTable==true && isTLC==false - * - * b. dataTalbe==false && isLayout==true (table is used - * for layout see respective method) - * - * c. isLayout == false && blockChilNodes==true - * - * d. nodeName.equalsIgnoreCase("div") - */ - - else if (display.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table") - || display.startsWith("table")) { - // step 5(ii) - if (nodeName.equalsIgnoreCase("div")) { - if (visibleBorder == true && isLayout == false) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - } - // step 5(iii) --flag that already identified TLC based on - // headings - else if (nodeName.equalsIgnoreCase("h1") - || nodeName.equalsIgnoreCase("h2")) { - TLC++; - isTLC = true; - headingTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - // step 5(iv) - else if (headingTLC == false && nodeName.equalsIgnoreCase("h3")) { - TLC++; - isTLC = true; - // headingTLC=true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - // step 5(v) - else if (headingTLC == false && nodeName.equalsIgnoreCase("h4")) { - TLC++; - isTLC = true; - // headingTLC=true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - - // step 5(vi) - else if (nodeName.equalsIgnoreCase("table") - || display.contains("table")) { - boolean dataTable = false; - boolean blockChilNodes = false; - NodeList tchildren = node.getChildNodes(); - if (tchildren != null) { - int len = tchildren.getLength(); - for (int i = 0; i < len; i++) { - // need to check if the table's children are thead - // or caption - String tchildName = tchildren.item(i).getNodeName(); - if (tchildName.equalsIgnoreCase("thead") - || tchildName.equalsIgnoreCase("caption")) { - dataTable = true; - dataTables++; - } - // check if there are block level child nodes - if (tchildren.item(i) instanceof IElementEx) { - IStyle childStyle = ((IElementEx) tchildren - .item(i)).getStyle(); - String displayChild = (String) childStyle - .get("display"); - if (displayChild.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table")) - blockChilNodes = true; - } - }// ends for-loop - } - - if (isTLC == false && dataTable == true) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - - else if (dataTable == false) { - tableCellLayout(node); - if (isLayout == true) { - if (isTLC == false) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - }// ends if isLayout=true - - else if (isLayout == false && blockChilNodes == true) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - else if (nodeName.equalsIgnoreCase("div")) { - TLC++; - isTLC = true; - // TLC - highlight - ((INodeEx) node).highlight(); - } - }// ends if dataTable=false - }// ends else-if table - }// ends else-if block - - // Recurse through the rest of the childrenNodes - NodeList NodeChildren = node.getChildNodes(); - if (NodeChildren != null) { - int len = NodeChildren.getLength(); - for (int i = 0; i < len; i++) { - visibleBorder = false; - countTLC(NodeChildren.item(i)); - } - } - }// end if element node - - return TLC; - }// end getBlockCount - - /* - * boolean singleChildren(node, length) This method is a help method for - * calculateTLC(). It checks for Nodes with only one child per child node OR - * zero nodes If that is the case, then we flag as singleChildren IFF the - * node's name is not table or tbody - */ - - public static boolean singleChildren(Node node, int length) { - int NodeLength = length; - // need to check all the node/tree - if (NodeLength == 1 || NodeLength == 0) { - if (!node.getNodeName().equalsIgnoreCase("table") - && !node.getNodeName().equalsIgnoreCase("tbody")) { - // if singlesChildren == true then need to check if the display - // is block if its zero - if (NodeLength == 0 && display.equalsIgnoreCase("block")) - singlesChildren = true; - else if (NodeLength == 1) - singlesChildren = true; - else if (NodeLength == 0 - && node.getNodeName().equalsIgnoreCase("img")) - singlesChildren = true; - else - singlesChildren = false; - } - } - return singlesChildren; - } - - /* - * backgroundCheck(node) This method is a help method for calculateTLC(). It - * determines a background color difference between a node and its parent - * node. THIS METHOD IS NOT USED - */ - - public static void backgroundCheck(Node node) { - backgroundDif = false; - boolean transparent = false; - if (node instanceof IElementEx) { - // get node's background colour - IStyle style = ((IElementEx) node).getStyle(); - backgroundColor = (String) style.get("backgroundColor"); - // get parent's background colour - Node parentNode = node.getParentNode(); - IStyle style2 = ((IElementEx) parentNode).getStyle(); - backgroundColorParent = (String) style2.get("backgroundColor"); - if (backgroundColorParent.equalsIgnoreCase("transparent")) { - Node grandParent = parentNode.getParentNode(); - IStyle style3 = ((IElementEx) grandParent).getStyle(); - // grandParent's color could still be transparent - // need a for-loop to reach the non-transparent parent - backgroundColorGrandParent = (String) style3 - .get("backgroundColor"); - transparent = true; - } - } - if (transparent == false) { - } - - if (!backgroundColor.equalsIgnoreCase(backgroundColorParent) - && !backgroundColor.equalsIgnoreCase("transparent") - && !backgroundColorParent.equalsIgnoreCase("transparent")) { - backgroundDif = true; - } - - }// ends backgroundCheck - - /* - * boolean tableCellLayout(node) This method is a help method for - * calculateTLC(). It determines the number of column and rows a node that - * identidied as table has and returns true if the table is used for layout - */ - - public static boolean tableCellLayout(Node node) { - isLayout = false; - int tableRows = 0; - int tableCols = 0; - // table-->tbody-->tr-->td - // get the children nodes of the tbody - Node tbody = node.getFirstChild(); - NodeList tbodyNodes = tbody.getChildNodes(); - // System.out.println(childNodes); - for (int i = 0; i < tbodyNodes.getLength(); i++) { - Node trnode = tbodyNodes.item(i); - String name = trnode.getNodeName(); - if (name.equalsIgnoreCase("tr")) { - rows++; - tableRows++; - }// ends if - // get the children of TR to find TD count - NodeList trChildNodes = trnode.getChildNodes(); - for (int j = 0; j < trChildNodes.getLength(); j++) { - Node tdnode = trChildNodes.item(j); - String name2 = tdnode.getNodeName(); - if (name2.equalsIgnoreCase("td")) { - tableCols++; - columns++; - } - }// ends j-for - }// ends i-for - - if (tableRows == 1 || tableCols == 1) { - layoutTable++; - isLayout = true; - } else if (tableRows == tableCols) { - if (tableRows != 0 && tableCols != 0) { - layoutTable++; - isLayout = true; - } - } - return isLayout; - }// ends tableCellLayout -}// ends class -
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/GridVariables.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/GridVariables.java deleted file mode 100644 index 08a3c3d..0000000 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/GridVariables.java +++ /dev/null
@@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 University of Manchester and Others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eleni Michailidou - initial API and implementation - *******************************************************************************/ -package org.eclipse.actf.examples.simplevisualizer.vicramtest; - -/* - * GridVarables is a helper method that stores the variables for each grid defined in Visualization.java - * The method also implements compareTo method that sorts an array based on a ascending order of TLC, images and then wordCount - */ -public class GridVariables implements Comparable { - public int TLC, images; - double wordCount; - public int row = -1; - public int column = -1; - - // public double gridVCS; - - public GridVariables(int TLC, int images, double wordCount) { - this.images = images; - this.TLC = TLC; - this.wordCount = wordCount; - } - - public double getGridVCS() { - return (1.743 + 0.097 * (TLC) + 0.053 * (wordCount) + 0.003 * (images)) / 10; - } - - public void setRow(int newRow) { - this.row = newRow; - } - - public void setCol(int newCol) { - this.column = newCol; - } - - // this allows java to srt the objects - public int compareTo(Object anotherGridVariables) throws ClassCastException { - if (!(anotherGridVariables instanceof GridVariables)) - throw new ClassCastException("A GridVariables object expected."); - int anotherGridTLC = ((GridVariables) anotherGridVariables).TLC; - int anotherGridImg = ((GridVariables) anotherGridVariables).images; - double anotherGridWC = ((GridVariables) anotherGridVariables).wordCount; - if (this.TLC == 0 && anotherGridTLC == 0) { - if (this.images == 0 && anotherGridImg == 0) { - if (this.wordCount >= anotherGridWC) { - return -1; - } else - return 1; - } else if (this.images >= anotherGridImg) { - return -1; - } else - return 1; - } - else if (this.TLC >= anotherGridTLC) { - return -1; - } else - return 1; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization.java deleted file mode 100644 index 8bc04af..0000000 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization.java +++ /dev/null
@@ -1,746 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 University of Manchester and Others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eleni Michailidou - initial API and implementation - *******************************************************************************/ -package org.eclipse.actf.examples.simplevisualizer.vicramtest; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.StringTokenizer; - -import org.eclipse.actf.model.dom.dombycom.IElementEx; -import org.eclipse.actf.model.dom.dombycom.INodeEx; -import org.eclipse.actf.model.dom.dombycom.IStyle; -import org.eclipse.actf.model.ui.IModelService; -import org.eclipse.actf.model.ui.util.ModelServiceUtils; -import org.eclipse.swt.graphics.Rectangle; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/* - * Visualization Algorithm - * Divides the page in x*y grids and the complexity for each grid is calculated - * Colours for each grid is assigned based on the complexity score of each grid and the VCS of the overall page - * This class uses the Complexity.java methods while identifying each grid variables - * - * One could change the number of: rows, columns, and the colour array list defined in the class - */ -public class Visualization { - - private static int[][] newOverlayPixels; - private static int webPageHeight, webPageWidth; - private static IModelService modelService; - private static int TLC, wordCount, images; - private static Element docLiveElement; - private static ArrayList[][] nodeGridArray; - public static int gridSize = 200; - public static int rows = 10; - public static int columns = 10; - private static GridVariables[][] gridVarArray; - private static int gridColumn; - private static int gridRow; - private static boolean isTLC, visibleBorder; - private static boolean findName; - private static boolean singlesChildren; - private static boolean headingTLC; - private static boolean isLayout; - private static Rectangle TLCRec; - private static double[][] gridVCSarray; - private static double gridVCS; - private static double visVCS; - private static String words; - private static int gridTLC; - private static boolean flag; - private static GridVariables[][] calcVCS; - private static int gridHeight; - private static int gridWidth; - public static String gridDescription; - - /* - * int[][] findElements() returns an int array with the new overlay pixels - * that the PartControlVisualizer uses to draw the overlay on top of the - * screenshot. - * This method: - * 1. Runs the Complexity.calculate() to get the overall VCS of the page - * - * 2. Resets variables used in the analysis - * - * 3. Determine the gridCellWidth and height in order to get coordinates of - * each grid based on the rows and columns count - * - * 4. Initialises Model and Document (based on LiveDom) and GridVariablesArray - * - * 5. Uses GridVariable.java to create Objects that stores the data for each grid - * based on the row and column location - */ - public static int[][] findElements(int[][] overlayPixels, - Rectangle imageSize, boolean flag) { - // will need some variables from the complexity algorithm so we run it first here - Complexity.calculate(); - newOverlayPixels = overlayPixels; - webPageHeight = imageSize.height; - webPageWidth = imageSize.width; - isTLC = false; - headingTLC = false; - singlesChildren = false; - visibleBorder = false; - gridTLC = 0; - gridVCS = 0; - visVCS = 0; - gridWidth = webPageWidth / columns; - gridHeight = webPageHeight / rows; - modelService = ModelServiceUtils.getActiveModelService(); - Document docLive = modelService.getLiveDocument(); - if (docLive != null) { - docLiveElement = docLive.getDocumentElement(); - gridVarArray = new GridVariables[rows][columns]; - gridVCSarray = new double[rows][columns]; - // and initialize arrays - for (int i = 0; i < rows; i++) { - for (int j = 0; j < columns; j++) { - gridVarArray[i][j] = new GridVariables(0, 0, 0); - } - } - Node node = docLiveElement.getElementsByTagName("body").item(0); - NodeList NodeChildren = node.getChildNodes(); - if (NodeChildren != null) { - int len = NodeChildren.getLength(); - for (int i = 0; i < len; i++) { - findTypeLoc(NodeChildren.item(i)); - findName = true; - singlesChildren = false; - isTLC = false; - headingTLC = false; - gridTLC = 0; - findTLCLoc(NodeChildren.item(i)); - } - } - } - String gridInfo = ""; - gridDescription = "----- Complexity Visualization View -----" - + "\nColour range: Red - Orange - Yellow - YellowGreen - Green - DarkGreen\n " - + "\nThe more to the red colour, the more visually complex the grid is." - + " The colours depend on the overall visual complexity of the page. " - + "The grids with the highest complexity score reflect the overall page's VCS; " - + "the more to the red the more visually complex the page is.\n" - + "\n ----- Grid Description: -----\n"; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < columns; j++) { - // sets the row and column in the gridVarArray - gridVarArray[i][j].setRow(i); - gridVarArray[i][j].setCol(j); - gridInfo = "Grid (row-column): " + i + "-" + j + " | Images: " - + gridVarArray[i][j].images + " | TLC: " - + gridVarArray[i][j].TLC + " | Word Count: " - + gridVarArray[i][j].wordCount + " | VCS = " - + gridVarArray[i][j].getGridVCS(); - gridDescription += "\n" + gridInfo; - } - } - determineColour(); - // create the grid lines - drawGridLines(); - return newOverlayPixels; - } - - /* - * findTypeLoc(node) - finds the type of the node and the location of the - * interested elements then it assigns the element by incrementing the - * appropriate counter in the appropriate grid - */ - public static void findTypeLoc(Node node) { - if (node == null) - return; - int type = node.getNodeType(); - if (type == Node.DOCUMENT_NODE) { - findTypeLoc(((Document) node).getDocumentElement()); - } - if (type == Node.ELEMENT_NODE) { - // checks and counts the type of element - String nodeName = node.getNodeName(); - if (nodeName.equalsIgnoreCase("img")) { - // find location of the image and assign to correct object and - // array position (grid array) - Rectangle imageRec = findGrid(node); - if (imageRec != null) { - if (imageRec.x >= 0 - && imageRec.y >= 0 - && (imageRec.x <= webPageWidth && imageRec.y <= webPageHeight)) { - if ((imageRec.height > gridHeight || imageRec.width > gridWidth)) { - // place and increament - gridVarArray[gridRow][gridColumn].images++; - } - } - } - }// ends node img - - // recurse to find the rest of the counters - NodeList children = node.getChildNodes(); - if (children != null) { - int len = children.getLength(); - for (int i = 0; i < len; i++) { - findTypeLoc(children.item(i)); - } - } - }// ends if (type == Node.ELEMENT_NODE) - // Get the word count - - if (type == Node.TEXT_NODE) { - // where the word count begins -need to get the number of rows and - // columns that the text node spans for (see below) - - String strWord = node.getNodeValue(); - int words = 0; - if (strWord != null) { - StringTokenizer total = new StringTokenizer(strWord, - "'?!@#$&*/-,:.<>()~;=_|"); - while (total.hasMoreTokens() == true) { - StringTokenizer token = new StringTokenizer(total - .nextToken()); - words += token.countTokens(); - if (words > 0) { - Rectangle textNodeRec = findGrid(node); - // System.out.println(textNodeRec); - if (textNodeRec != null) { - int spanCol = 0; - int spanRow = 0; - double wordsPerGrid = 0; - boolean spanWords = false; - // find the range of the words span: columns: - // words/width of rectangle, rows: words/height of rectangle - // need to check that the x and yth coordinate of the rectangle falls within the webpage height and width - if (textNodeRec.x >= 0 - && textNodeRec.y >= 0 - && (textNodeRec.x <= webPageWidth && textNodeRec.y <= webPageHeight)) { - if ((textNodeRec.height > gridHeight || textNodeRec.width > gridWidth) - && words > 1) { - spanWords = true; - spanCol = textNodeRec.width / gridWidth; - spanRow = textNodeRec.height / gridHeight; - int spanCol2 = spanCol; - int spanRow2 = spanRow; - if (spanCol == 0) - spanCol2 = 1; - if (spanRow == 0) - spanRow2 = 1; - if (words > 1) - wordsPerGrid = ((double) words / ((double) spanCol2 * (double) spanRow2)); - else if (words > 0 && words <= 1) - wordsPerGrid = words; - } - if (spanWords == true) { - int maxCol = gridColumn + spanCol; - int maxRow = gridRow + spanRow; - if (maxCol >= columns) - maxCol = columns - 1; - if (maxRow >= rows) - maxRow = rows - 1; - if (spanRow == 0) { - for (int j = gridColumn; j <= maxCol; j++) { - gridVarArray[gridRow][j].wordCount += wordsPerGrid; - } - } - if (spanCol == 0) { - for (int i = gridRow; i <= maxRow; i++) { - gridVarArray[i][gridColumn].wordCount += wordsPerGrid; - } - } else if (spanCol > 0 && spanRow > 0) { - for (int i = gridRow; i <= maxRow; i++) { - for (int j = gridColumn; j <= maxCol; j++) { - gridVarArray[i][j].wordCount += wordsPerGrid; - } - } - } - }// ends if span = true - else { - gridVarArray[gridRow][gridColumn].wordCount += words; - } - } - }// end if rec not null - }// ends if words>0 - }// ends while loop - } - }// ends if (type == Node.TEXT_NODE) - } - - /* - * Rectangle findGrid(node) - returns the rectangle that the node's top left - * point fits within in this method is used to find the row and column of - * the grid - */ - public static Rectangle findGrid(Node node) { - - gridColumn = 0; - gridRow = 0; - Rectangle nodeRectangle = null; - if (node instanceof IElementEx) { - nodeRectangle = ((IElementEx) node).getLocation(); - // if width or height are zero = return null - if (nodeRectangle.height == 0 || nodeRectangle.width == 0 - || nodeRectangle.x < 0 || nodeRectangle.x > webPageWidth - || nodeRectangle.y < 0 || nodeRectangle.y > webPageHeight) { - nodeRectangle = null; - } - - // need to check the x and y point and respectively assign to the - // appropriate grid's list - - else { - if (nodeRectangle.x < 1 && nodeRectangle.x >= 0 - && nodeRectangle.y > 0) { - gridColumn = 0; - gridRow = (nodeRectangle.y) / gridHeight; - } else if (nodeRectangle.y < 1 && nodeRectangle.y >= 0 - && nodeRectangle.x > 0) { - gridRow = 0; - gridColumn = (nodeRectangle.x) / gridWidth; - } else { - gridRow = (nodeRectangle.y) / gridHeight; - gridColumn = (nodeRectangle.x) / gridWidth; - } - } - }// ends if node an element - else if (node instanceof INodeEx) { - // for text nodes - /* - * Should calculate the word count 2. Find the width of the node and - * calculate the span range 3. by calculating the wordCount/ - */ - nodeRectangle = ((INodeEx) node).getLocation(); - if (nodeRectangle.height == 0 || nodeRectangle.width == 0 - || nodeRectangle.x < 0 || nodeRectangle.x > webPageWidth - || nodeRectangle.y < 0 || nodeRectangle.y > webPageHeight) { - nodeRectangle = null; - } - // need to check the x and y point and respectively assign to the - // appropriate grid's list - else { - if (nodeRectangle.x < 1 && nodeRectangle.x >= 0 - && nodeRectangle.y > 0) { - gridColumn = 0; - gridRow = (nodeRectangle.y) / gridHeight; - } else if (nodeRectangle.y < 1 && nodeRectangle.y >= 0 - && nodeRectangle.x > 0) { - gridRow = 0; - gridColumn = (nodeRectangle.x) / gridWidth; - } else { - gridRow = (nodeRectangle.y) / gridHeight; - gridColumn = (nodeRectangle.x) / gridWidth; - } - } - }// ends if node a TEXT_node - // need to check that the assign gridRow and gridColumn does not exceed - // the gridVarArray size - if (gridRow >= rows) - gridRow = rows - 1; - if (gridColumn >= columns) - gridColumn = columns - 1; - return nodeRectangle; - } - - /* - * findTLCLoc(node) This method mirrors the countTLC() method from - * Complexity.java. The addition is that we determine the grid location that - * the TLC belongs into FOR DESCRIPTION ON ALGORITHM SEE COMMENTS ON - * COMPLEXITY.JAVA' REPSECTIVE METHOD - */ - public static void findTLCLoc(Node node) { - - String display = null; - String borderWidth = null; - if (node == null) - return; - int type = node.getNodeType(); - if (type == Node.DOCUMENT_NODE) { - findTLCLoc(((Document) node).getDocumentElement()); - } - if (type == Node.ELEMENT_NODE) { - if (node instanceof IElementEx) { - IStyle style = ((IElementEx) node).getStyle(); - display = (String) style.get("display"); - borderWidth = (String) style.get("borderWidth"); - if (node.getNodeName().equalsIgnoreCase("div")) { - int borderLen = borderWidth.length(); - boolean isPx = borderWidth.contains("px"); - int px = 0; - if (isPx == true) { - StringTokenizer borderToken = new StringTokenizer( - borderWidth, " "); - String pixels = ""; - String borderPx = ""; - while (borderToken.hasMoreTokens() == true) { - String token = borderToken.nextToken(); - if (token.contains("px") == true) { - int tokenLength = token.length(); - borderPx = token.substring(0, tokenLength - 2); - } - } - px = Integer.parseInt(borderPx); - if (px > 0) { - visibleBorder = true; - } else - visibleBorder = false; - } - } - } - if (display == null) { - display = ""; - } - NodeList children = node.getChildNodes(); - int len = 0; - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - int childType = child.getNodeType(); - if (childType == 1) - len++; - } - boolean blockChild = false; - boolean lastIsImg = false; - String nodeName = node.getNodeName(); - if (len == 1) { - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeName().equalsIgnoreCase("img")) { - lastIsImg = true; - } - } - } - if (findName == true) { - if (children != null) { - Node childNode = children.item(0); - singlesChildren = Complexity.singleChildren(node, len); - for (int i = 0; i < len; i++) { - childNode = children.item(i); - NodeList childNodeList = childNode.getChildNodes(); - int length = childNodeList.getLength(); - singlesChildren = Complexity.singleChildren(node, len); - if (childNode instanceof IElementEx) { - IStyle childStyle = ((IElementEx) childNode) - .getStyle(); - String displayChild = (String) childStyle - .get("display"); - if (displayChild.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table")) - blockChild = true; - } - }// end for-loop - }// end if not null children - if (display.equalsIgnoreCase("block") && blockChild == false) { - TLCRec = findGrid(node); - if (TLCRec != null) { - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - else if (singlesChildren == true && isTLC == false) { - TLCRec = findGrid(node); - if (TLCRec != null) { - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - findName = false; - } - else if (nodeName.equalsIgnoreCase("div")) { - if (visibleBorder == true) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increament - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - } - else if (display.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table") - || display.startsWith("table")) { - if (nodeName.equalsIgnoreCase("div")) { - if (visibleBorder == true && isLayout == false) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increment - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - } - else if (nodeName.equalsIgnoreCase("h1") - || nodeName.equalsIgnoreCase("h2")) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increment - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - headingTLC = true; - }// ends if case 2 (if nodeName equals h1 or h2) - - else if (headingTLC == false && nodeName.equalsIgnoreCase("h3")) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increment - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - else if (headingTLC == false && nodeName.equalsIgnoreCase("h4")) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increment - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - else if (nodeName.equalsIgnoreCase("table") - || display.contains("table")) { - boolean dataTable = false; - boolean blockChilNodes = false; - NodeList tchildren = node.getChildNodes(); - if (tchildren != null) { - len = tchildren.getLength(); - for (int i = 0; i < len; i++) { - String tchildName = tchildren.item(i).getNodeName(); - if (tchildName.equalsIgnoreCase("thead") - || tchildName.equalsIgnoreCase("caption")) { - dataTable = true; - } - if (tchildren.item(i) instanceof IElementEx) { - IStyle childStyle = ((IElementEx) tchildren - .item(i)).getStyle(); - String displayChild = (String) childStyle - .get("display"); - if (displayChild.equalsIgnoreCase("block") - || display.equalsIgnoreCase("table")) - blockChilNodes = true; - } - }// ends for-loop - } - if (isTLC == false && dataTable == true) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increament - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - else if (dataTable == false) { - isLayout = Complexity.tableCellLayout(node); - if (isLayout == true) { - if (isTLC == false) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increament - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - }// ends if isLayout=true - else if (isLayout == false && blockChilNodes == true) { - // count if there are block level child nodes - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increament - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } else if (nodeName.equalsIgnoreCase("div")) { - TLCRec = findGrid(node); - if (TLCRec != null) { - // place and increament - gridVarArray[gridRow][gridColumn].TLC++; - } - isTLC = true; - } - }// ends if dataTable=false - }// ends else-if table - }// ends else-if block - NodeList NodeChildren = node.getChildNodes(); - if (NodeChildren != null) { - len = NodeChildren.getLength(); - for (int i = 0; i < len; i++) { - visibleBorder = false; - findTLCLoc(NodeChildren.item(i)); - } - } - }// end if element node - }// ends findTLCLoc - - /* - * determineColour this method identifies the colour that each grid will be - * assigned with - * - * the colour depends on the ratio of gridVCS/complexity.VCS - * - * first we need to know the colour assigned overall based on the complexity.VCS: - * 0-3.5 Simple yellow - * - * 3.5 - 6.5 Medium green - * - * 6.5 - 10 Complex red - * - * then sort the gridVCSarray based on ascending order. The 5 grids with the highest score - * are assigned with the page's complexity VCS colour then the rest based on - * the colour scale - */ - public static void determineColour() { - // get complexity score of the whole page - double compVCS = Complexity.VCS; - String complexity = ""; - int startColour = 0xC0C0C0; - // determine page's complexity level array and starting colour - // colours: http://www.webmonkey.com/reference/Color_Charts - // colours array:red/orange/gold/yellow/yellowgreen/lime/green/darkgreen - // //{0xFF0000, 0xFFA500,0xFFD700,0xFFFF00,0x9ACD32,0x00FF00,0x008000, - // 0x006400}; - // darkgreen = the minScoreColour - int[] colours = { 0x3D1AED, 0x4CB7FF, 0x00D4FF, 0x00ff77, 0x00C000 }; - int minScoreColour = 0x006400;// for scores <=0.1743 - int colourLen = colours.length; - // if the length is even or odd - boolean colourLenEven = false; - if (colourLen % 2 == 0) - colourLenEven = true; - int pageColour = -1; - // assign initial colour of page based on its overall VCS complexity - if (compVCS < 3) { - complexity = "simple"; - if (colourLenEven) - pageColour = ((colourLen / 3) * 2) - 1; - else - pageColour = ((colourLen / 3) * 2); - startColour = colours[pageColour]; - } else if (compVCS >= 3 && compVCS < 6) { - complexity = "medium"; - if (colourLenEven) - pageColour = (colourLen / 3) - 1; - else - pageColour = (colourLen / 3); - startColour = colours[pageColour]; - } else if (compVCS >= 6) { - complexity = "complex"; - pageColour = 0;// always the first index - startColour = colours[pageColour]; - } - - double[][] sortVCSarray = new double[rows][columns]; - - // Create a single array now that is the size of the doubel array - GridVariables[] sortVCS = new GridVariables[rows * columns]; - // now populate by going through the double array and extracting the - // Data - // HERE we can find the number of grids that have the minimum value of - // VCS (<=0.1743) which - // will help later for the calculation of gridsPerColour. The dark green - // is only assigned to those - int counter = 0; - int minScore = 0; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < columns; j++) { - sortVCS[counter] = gridVarArray[i][j]; - counter++; - if (gridVarArray[i][j].getGridVCS() <= 0.1743) - minScore++; - } - } - // sort the array - based on the sort method extended in - // GridVariables.java - Arrays.sort(sortVCS); - /* - * The following code decides the color for each grid based on the colorIndex of the page and the number of grids the colorIndex is - * calculated based on the VCS score of the page and is the starting color of the page then the number of grids per color depends on the - * location of the colorIndex on the colourArray colors[] - * numGridsPerColor = (numGrids/(color.length - ColorIndex - 1)) - */ - int numGrids = rows * columns; - int coloursBasedScore = colourLen - pageColour; - int gridsPerColour = (numGrids - minScore) / coloursBasedScore; - int counter2 = 0; - int counterMaxIndex = 0;// this can go up to 3 inclusive - int gridColour = pageColour; - // System.out.println(colourLen+"gridsPerColour= "+ gridsPerColour + - // ", coloursBasedScore = "+ coloursBasedScore+ ", page colour="+ - // pageColour); - for (int j = 0; j < sortVCS.length; j++) { - if (sortVCS[j].getGridVCS() <= 0.1743) { - // System.out.println("in <=0.1743"); - gridColour = minScoreColour; - colour(sortVCS[j].row, sortVCS[j].column, minScoreColour); - } else { - // System.out.println("in else"); - if (counter2 == gridsPerColour) { - counter2 = 0; - gridColour++; - } - if (gridColour == colourLen) { - gridColour = colourLen - 1;// the max colour - } - colour(sortVCS[j].row, sortVCS[j].column, colours[gridColour]); - } - counter2++; - } - } - - /* - * Colours the nodes based on the coordinates and colour - */ - public static void colour(int gRow, int gCol, int colour) { - // - // get the row and column of the grid - // gridRow - // colour = 0x00D4FF; - int x1 = gCol * gridWidth; - int y1 = gRow * gridHeight; - int x2 = gridWidth + x1; - int y2 = gridHeight + y1; - // System.out.println("Coordinates: x1 - "+ x1+ ", y1 - "+y1+",x2 - " + x2+", y2 - "+y2); - for (int b = y1; b < (y2); b++) { - for (int a = x1; a < (x2); a++) { - if (flag) { - newOverlayPixels[a][b] = colour; - } else { - newOverlayPixels[b][a] = colour; - } - } - } - } - /* - * drawGridLines() draws lines around the grids to easily differentiate - * between rectangles/grids - */ - public static void drawGridLines() { - // horizontal lines - int x1 = 0; - int x2 = webPageWidth; - int y1 = 0; - int y2 = webPageHeight; - for (int b = y1; b < rows; b++) { - for (int a = x1; a < (x2); a++) { - if (flag) { - newOverlayPixels[a][b * gridHeight] = 0x000000; - } else { - newOverlayPixels[b * gridHeight][a] = 0x000000; - } - } - } - // vertical lines - x2 = 0; - // b-Y, a - X - for (int b = y1; b < y2; b++) { - for (int a = x1; a < columns; a++) { - if (flag) { - newOverlayPixels[a * gridWidth][b] = 0x000000; - } else { - newOverlayPixels[b][a * gridWidth] = 0x000000; - } - } - } - } -}
diff --git a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization2.java b/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization2.java deleted file mode 100644 index 917ec1d..0000000 --- a/plugins/org.eclipse.actf.examples.simplevisualizer/src/org/eclipse/actf/examples/simplevisualizer/vicramtest/Visualization2.java +++ /dev/null
@@ -1,456 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 University of Manchester and Others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eleni Michailidou - initial API and implementation - *******************************************************************************/ -package org.eclipse.actf.examples.simplevisualizer.vicramtest; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Map; - -import org.eclipse.actf.model.dom.dombycom.IElementEx; -import org.eclipse.actf.model.dom.dombycom.INodeEx; -import org.eclipse.actf.model.ui.IModelService; -import org.eclipse.actf.model.ui.editor.browser.ICurrentStyles; -import org.eclipse.actf.model.ui.util.ModelServiceUtils; -import org.eclipse.swt.graphics.Rectangle; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/* - * Visualization Class: - * Gives a heatmap of the page similar to an eye tracking heatmap. The eye tracking heatmap uses colours to indicates the level - * of attention each area receives based on the number of fixations that each area had. Fixations are the number of times that participants looked - * at that area. - * The visualization code will duplicate these results based on results derived from eye tracking studies. - * Red Areas of most attention: Images - * 2-3 First Items on Menus - * Yellow - * Green - * Gray - * - * - * The visualization code is based on the Complexity.java code. Since it is used to identify the structural elements we will send information from there (:S) - */ - -public class Visualization2 { - - private static Rectangle rectangle; - private static IModelService modelService; - private static Map<String, ICurrentStyles> styleMap; - private static int[][] newOverlayPixels; - private static boolean flag; - private static int webPageHeight; - private static int webPageWidth; - private static ArrayList<Rectangle> listItems, images, redCoordList, - yellowCoordList, greenCoordList, redCoordImg, yellowCoordImg, - greenCoordImg; - - public static int[][] findElements(int[][] overlayPixels, - Rectangle imageSize, boolean flag) { - - newOverlayPixels = overlayPixels; - webPageHeight = imageSize.height; - webPageWidth = imageSize.width; - System.out.println("Image Size: Height " + webPageHeight + "width " - + webPageWidth); - modelService = ModelServiceUtils.getActiveModelService(); - // listItems = new Rectangle[]; - - Document doc = modelService.getDocument(); - Document docLive = modelService.getLiveDocument(); - - listItems = new ArrayList<Rectangle>(); - images = new ArrayList<Rectangle>(); - redCoordList = new ArrayList<Rectangle>(); - yellowCoordList = new ArrayList<Rectangle>(); - greenCoordList = new ArrayList<Rectangle>(); - redCoordImg = new ArrayList<Rectangle>(); - yellowCoordImg = new ArrayList<Rectangle>(); - greenCoordImg = new ArrayList<Rectangle>(); - - if (doc != null || docLive != null) { - - // get document element - // identify tag name and node type - - // Element docElement = doc.getDocumentElement(); - Element docLiveElement = docLive.getDocumentElement(); - // call methods that identify the elements that will be highlighted - // for attention - // and calculate final score for VCS and aesthetics - Node node = docLiveElement.getElementsByTagName("body").item(0); - identifyElements(node); - determineColour(); - // identifyElements(docElement.getElementsByTagName("body").item(0)); - } - - return newOverlayPixels; - - } - - /* - * identifyElements: identifies what the node elements are - * (img/p/lists/menus etc) finds the coordinates of the interested elements - * and assignes them in the appropriate coordinate Array (or Object) - */ - public static void identifyElements(Node node) { - if (node == null) - return; - - int type = node.getNodeType(); - // System.out.print("Type: " +type + "Name: " + node.getNodeName()); - if (type == Node.DOCUMENT_NODE) { - identifyElements(((Document) node).getDocumentElement()); - } - if (type == Node.ELEMENT_NODE) { - // checks and counts the type of element - String nodeName = node.getNodeName(); - System.out.println("NodeName: " + nodeName); - - if (nodeName.equalsIgnoreCase("a")) { - - } - - if (nodeName.equalsIgnoreCase("p")) { - - } - - if (nodeName.equalsIgnoreCase("img")) { - // Get the location of the image - - if (node instanceof IElementEx) { - // IStyle style = ((IElementEx)node).getStyle(); - // TO DO: FIND SIZE OF IMAGE - THE BIGGEST IMAGE GETS THE - // RED COLOR - // THE LOCATION OF THE IMAGE WITH RESPECT TO THE SIZE OF THE - // PAGE MATTERS - /* - * Put the image found in an array and sort it based on its - * width and height size. The image with the largest size - * and if it is located within the top quearter of the page - * is assigned the red color. - */ - rectangle = ((IElementEx) node).getLocation(); - System.out.println("Rectangle: " + rectangle); - // highlight on the left for testing purposes - // ((INodeEx) node).highlight(); - // colour if the (x2,y2) point of the node is in the top - // half of the page - // check for first quarter since colourNode does not work - // for points on the very right hand side of the page - // int pointX2 = rectangle.width + rectangle.x; - // int pointY2 = rectangle.height + rectangle.y; - if (rectangle.y < (webPageHeight / 2)) { // && pointX2 < - // (webPageWidth/2)){ - // if(rectangle.height > 90 && rectangle.width >90){ - if (rectangle.height > 5 && rectangle.width > 5) { - images.add(rectangle); - // colourNodes(rectangle,0x3D1AED); - ((INodeEx) node).highlight(); - } - - } - - } - - // System.out.println("Image Rectangle: "+ rectangle); - - } - - if (nodeName.equalsIgnoreCase("form")) { - - } - - if (nodeName.equalsIgnoreCase("table")) { - - } - - if (nodeName.equalsIgnoreCase("ul") - || nodeName.equalsIgnoreCase("ol")) { - - if (node instanceof IElementEx) { - // IStyle style = ((IElementEx)node).getStyle(); - /* - * THE LOCATION OF THE list WITH RESPECT TO THE SIZE OF THE - * PAGE MATTERS -- Y1 point needs to be in the top half of - * the page -- need to find location of the first 3 items of - * the menu which will be coloured - */ - // location of the list - rectangle = ((IElementEx) node).getLocation(); - // - /* - * If listItems <=3, then color the whole list node else - * color the first three list items (find location of the - * first three <li> nodes) OR send to colour the first three - * <li> elements - * - * CASE: Multiple lists <ol>/<ul> under the same column - * Solution attempt: to put all list items in an array. Then - * colour the 3 first items with the same x1 (and/or x2) - * point see following method - */ - if (rectangle.y < (webPageHeight / 2)) { - - // create array that will put the list items with the - // same X1 point - - // recurse to find the number of items of the list - NodeList listChildren = node.getChildNodes(); - int nodelistItems = 0; - if (listChildren != null) { - int len = listChildren.getLength(); - for (int i = 0; i < len; i++) { - // System.out.println("List Rectangle: "+ - // rectangle + " List Items: "+ nodelistItems); - if (listChildren.item(i).getNodeName() - .equalsIgnoreCase("li")) { - nodelistItems++; - rectangle = ((IElementEx) listChildren - .item(i)).getLocation(); - int listItemsLen = listItems.size(); - System.out.println("length" + listItemsLen); - listItems.add(rectangle); - - } - } - - } - // test - for (int k = 0; k < listItems.size(); k++) - System.out.println("list item " + k + "- " - + listItems.get(k)); - - } - - } - - } - - // recurse to find the rest of the counters - NodeList children = node.getChildNodes(); - if (children != null) { - int len = children.getLength(); - for (int i = 0; i < len; i++) { - identifyElements(children.item(i)); - } - } - }// ends if (type == Node.ELEMENT_NODE) - - if (type == Node.TEXT_NODE) { - // where the word count begins - - // String string = node.getNodeValue(); - // words = " "+ string; - // if (words == null) - // wordCount = 0; - // else - // { - // StringTokenizer total = new StringTokenizer(words, - // "'?!@#$&*/-,:.<>()~;=_"); - // int count2 = 0; - // while (total.hasMoreTokens() == true) - // { - // StringTokenizer token = new StringTokenizer(total.nextToken()); - // wordCount += token.countTokens(); - // } - // } - - }// ends if (type == Node.TEXT_NODE) - } - - /* - * DetermineColour This method works on the arrays created in - * identifyElements and determines the colour for each of the elements This - * method is called from the main method since need to finish the whole - * page's element identification before colouring For example: listItems[] - - * need to call the first 3 items with the same X point to red colour, then - * 1 with yellow and 1 with green - */ - public static void determineColour() { - /* - * do for images what did for lists (put them in a list and red the two - * with the largest area ) - */ - if (images.size() > 0) { - ArrayList<Rectangle> imagesByArea = images; - Collections.sort(imagesByArea, new Comparator<Rectangle>() { - - public int compare(Rectangle o1, Rectangle o2) { - if ((o1.width * o1.height) > (o2.width * o2.height)) { - return -1; - } else { - return 1; - } - } - }); - // display elements of ArrayList - System.out - .println("ArrayList elements after sorting in descending order of Area : "); - for (int i = 0; i < imagesByArea.size(); i++) - System.out.println(imagesByArea.get(i)); - /* - * Need to call the first 3 items to red colour, then 4 with yellow - * and 1 with green - */ - int counter = 0; - for (int i = 0; i < imagesByArea.size(); i++) { - if (counter <= 3) { - redCoordList.add(imagesByArea.get(i)); - } else if (counter > 3 && counter <= 6) { - yellowCoordList.add(imagesByArea.get(i)); - } else if (counter == 7) { - greenCoordList.add(imagesByArea.get(i)); - } - - counter++; - } - - } - - // color Red = 0x3D1AED, the 3 first list items with the same x1 - - if (listItems.size() > 0) { - - /* - * To sort an ArrayList object, use Collection.sort and implement - * Comparator method. - */ - // arrayList by the X coordinate - ArrayList<Rectangle> listItemsByX = listItems; - Collections.sort(listItemsByX, new Comparator<Rectangle>() { - - public int compare(Rectangle o1, Rectangle o2) { - if (o1.x <= o2.x) { - return -1; - } else { - return 1; - } - } - }); - /* - * TESTING ARRAY Sort - */ - // display elements of ArrayList - System.out - .println("ArrayList elements after sorting in ascending order of Point X : "); - for (int i = 0; i < listItemsByX.size(); i++) - System.out.println(listItemsByX.get(i)); - - /* - * Need to call the first 3 items with the same X point to red - * colour, then 1 with yellow and 1 with green - */ - int counterX = 0; - int pointX = listItemsByX.get(0).x; - System.out.println("Point X: " + pointX); - // redColour - redCoordList.add(listItemsByX.get(0)); - for (int i = 1; i < listItemsByX.size(); i++) { - if (pointX == listItemsByX.get(i).x && counterX < 3) { - redCoordList.add(listItemsByX.get(i)); - } else if (pointX == listItemsByX.get(i).x - && (counterX == 3 || counterX == 4)) { - yellowCoordList.add(listItemsByX.get(i)); - } else if (pointX == listItemsByX.get(i).x && counterX == 5) { - greenCoordList.add(listItemsByX.get(i)); - } else if (pointX != listItemsByX.get(i).x) { - counterX = 0; - pointX = listItemsByX.get(i).x; - } - counterX++; - } - // do the same for horizontal lists - // arrayList by the Y coordinate - for horizontal menu - ArrayList<Rectangle> listItemsByY = listItems; - Collections.sort(listItemsByY, new Comparator<Rectangle>() { - - public int compare(Rectangle o1, Rectangle o2) { - if (o1.y <= o2.y) { - return -1; - } else { - return 1; - } - } - }); - int counterY = 0; - int pointY = listItemsByY.get(0).y; - System.out.println("Point Y: " + pointY); - // redColour - redCoordList.add(listItemsByY.get(0)); - for (int i = 1; i < listItemsByY.size(); i++) { - if (pointY == listItemsByY.get(i).y && counterY < 3) { - redCoordList.add(listItemsByY.get(i)); - } else if (pointY == listItemsByY.get(i).y - && (counterY == 3 || counterY == 4)) { - yellowCoordList.add(listItemsByY.get(i)); - } else if (pointY == listItemsByY.get(i).y && counterY == 5) { - greenCoordList.add(listItemsByY.get(i)); - } else if (pointY != listItemsByY.get(i).y) { - counterY = 0; - pointY = listItemsByY.get(i).y; - } - counterY++; - } - - /* - * TESTING ARRAY Sort - */ - // System.out.println("ArrayList elements after sorting in ascending order of Point Y : "); - // for(int i=0; i<listItemsByY.size(); i++) - // System.out.println(listItemsByY.get(i)); - // End testing - - // send to colour - for (int i = 0; i < redCoordList.size(); i++) - colourNodes(redCoordList.get(i), 0x3D1AED); - for (int i = 0; i < yellowCoordList.size(); i++) - colourNodes(yellowCoordList.get(i), 0x00D4FF); - for (int i = 0; i < greenCoordList.size(); i++) - colourNodes(greenCoordList.get(i), 0x008000); - - } - } - - /* - * Colours the nodes based on the coordinates and colour - */ - public static void colourNodes(Rectangle coordinates, int colour) { - // colour = 0x00D4FF; - int x1 = coordinates.x; - int y1 = coordinates.y; - int x2 = (coordinates.width) + x1; - int y2 = (coordinates.height) + y1; - System.out.println("Coordinates: x1 - " + x1 + ", y1 - " + y1 - + ",x2 - " + x2 + ", y2 - " + y2); - - // colour test - /* - * for (int b = 40; b < 400; b++) { for (int a = 50; a < 600; a++) { if - * (flag) { newOverlayPixels[b][a] = colour; } else { - * newOverlayPixels[a][b] = colour; } } } - */ - - for (int b = y1; b < (y2); b++) { - for (int a = x1; a < (x2); a++) { - if (flag) { - newOverlayPixels[a][b] = colour; - } else { - newOverlayPixels[b][a] = colour; - } - } - } - - } - -}
diff --git a/plugins/org.eclipse.actf.examples.vicram/META-INF/MANIFEST.MF b/plugins/org.eclipse.actf.examples.vicram/META-INF/MANIFEST.MF index 383b0a8..a137ca2 100644 --- a/plugins/org.eclipse.actf.examples.vicram/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.actf.examples.vicram/META-INF/MANIFEST.MF
@@ -17,6 +17,9 @@ org.eclipse.actf.model.ui.editors.ie, org.eclipse.actf.visualization.ui.report, org.eclipse.ui.views, - org.eclipse.actf.util.vocab + org.eclipse.actf.util.vocab, + org.eclipse.e4.ui.model.workbench, + org.eclipse.e4.ui.workbench, + org.eclipse.e4.core.contexts Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ApplicationWorkbenchWindowAdvisor.java b/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ApplicationWorkbenchWindowAdvisor.java index 2f30f08..72da531 100644 --- a/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ApplicationWorkbenchWindowAdvisor.java +++ b/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ApplicationWorkbenchWindowAdvisor.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and Others + * Copyright (c) 2006, 2015 IBM Corporation and Others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,14 +10,18 @@ *******************************************************************************/ package org.eclipse.actf.examples.vicram; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IMenuManager; import org.eclipse.ui.IWorkbenchPreferenceConstants; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.application.WorkbenchWindowAdvisor; +import org.eclipse.ui.internal.WorkbenchWindow; public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @@ -43,6 +47,7 @@ configurer.setShowStatusLine(true); configurer.setTitle(VicramPlugin .getResourceString("vicram.window.title")); //$NON-NLS-1$ + } public void postWindowOpen() { @@ -57,6 +62,18 @@ items[i].dispose(); } } + + // hide quick access (for Eclipse 4.2.x) + try { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + MWindow model = ((WorkbenchWindow) window).getModel(); + EModelService modelService = model.getContext().get( + EModelService.class); + modelService.find("SearchField", model).setToBeRendered(false); + } catch (Exception e) { + + } } }
diff --git a/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ui/perspectives/ComplexityVisualizationPerspective.java b/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ui/perspectives/ComplexityVisualizationPerspective.java index e41ac56..d6f5dca 100644 --- a/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ui/perspectives/ComplexityVisualizationPerspective.java +++ b/plugins/org.eclipse.actf.examples.vicram/src/org/eclipse/actf/examples/vicram/ui/perspectives/ComplexityVisualizationPerspective.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and Others + * Copyright (c) 2009, 2015 IBM Corporation and Others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,13 +25,13 @@ public void createInitialLayout(IPageLayout layout) { layout.setEditorAreaVisible(true); - + try { PerspectiveListenerForBrowserLaunch.setTargetUrl(new URL( - "http://www.eclipse.org/actf")); + "https://projects.eclipse.org/projects/technology.actf/")); } catch (MalformedURLException e) { } - + PlatformUI.getWorkbench().getActiveWorkbenchWindow() .addPerspectiveListener( new PerspectiveListenerForBrowserLaunch(ID));