1// BEGIN LICENSE BLOCK 2// Version: CMPL 1.1 3// 4// The contents of this file are subject to the Cisco-style Mozilla Public 5// License Version 1.1 (the "License"); you may not use this file except 6// in compliance with the License. You may obtain a copy of the License 7// at www.eclipse-clp.org/license. 8// 9// Software distributed under the License is distributed on an "AS IS" 10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11// the License for the specific language governing rights and limitations 12// under the License. 13// 14// The Original Code is The ECLiPSe Constraint Logic Programming System. 15// The Initial Developer of the Original Code is Cisco Systems, Inc. 16// Portions created by the Initial Developer are 17// Copyright (C) 2006 Cisco Systems, Inc. All Rights Reserved. 18// 19// Contributor(s): 20// 21// END LICENSE BLOCK 22 23package com.parctechnologies.eclipse.visualisation; 24 25import java.awt.*; 26import java.awt.event.*; 27import java.util.*; 28import javax.swing.*; 29 30/** 31 * The concept of Viewer is key to the vis client architecture. A Viewer is an 32 * object which is monitoring a viewable. The viewer can react to events 33 * concerning the viewable it is monitoring. A viewer has two main 34 * groups of methods: 35 * <ol> 36 * <li> Methods relating to its reaction to events. These correspond to the 37 * progression through the different stages of an event. These methods are: 38 * prepareForEvent, collectPreEventGoals, startEvent, shouldHold, stopEvent, 39 * get/setInterestSpec. The methods are invoked by the ViewerManager at the 40 * different stages of an event which the Viewer is participating in. 41 * <li> Methods relating to the graphical display of the viewer. These are: 42 * get/setDescription, getComponent, getJMenuBar, gain/loseFocus. These are 43 * mainly invoked by the ViewerManagerFrame. 44 */ 45public interface Viewer extends SymRefable 46{ 47 /** signals that the argument event is about to start. The viewer must make 48 * preparations so that it can return pre event goals. 49 */ 50 void prepareForEvent(VisEvent event); 51 52 /** queries the viewers for a batched set of goals that it would like 53 * executed before the argument event starts. 54 */ 55 BatchGoal collectPreEventGoals(VisEvent event); 56 57 /** 58 * Returns the results of the requested pre-event goals to the viewer, at 59 * the same time signalling to it that the event is starting. 60 */ 61 void startEvent(VisEvent event, java.util.List goalResults); 62 63 /** 64 * During an event, queries the viewer as to whether it would like the 65 * vis client to "hold" i.e. retain control before allowing ECLiPSe to 66 * continue execution. 67 */ 68 boolean shouldHold(); 69 70 /** signals that the current event is finishing */ 71 void stopEvent(); 72 73 /** 74 * Queries the viewer for the interest spec it requires in order to monitor 75 * the viewable. 76 */ 77 InterestSpec getInterestSpec(); 78 79 void setInterestSpec(InterestSpec interestSpec); 80 81 String getDescription(); 82 83 void setDescription(String description); 84 85 void setViewerManager(ViewerManager viewerManager); 86 87 void close(); 88 89 /** 90 * Query the Viewer for the GUI Component which is its graphical 91 * representation. 92 */ 93 Component getComponent(); 94 95 96 /** 97 * Query the Viewer for the viewable which it is monitoring. 98 */ 99 Viewable getViewable(); 100 101 102 /** 103 * Query the Viewer for the JMenuBar to be used if the viewer is to appear 104 * in a RootPane. 105 */ 106 JMenuBar getJMenuBar(); 107 108 void gainFocus(); 109 110 void loseFocus(); 111 112 void setStateModel(VisClientStateModel stateModel); 113 114 /** Returns the dimensions of the Viewer */ 115 Rectangle getBounds(); 116 117 /** Sets the dimensions of the Viewer */ 118 void setBounds(Rectangle rectangle); 119 120 /** zoom to new zoom level */ 121 void zoomToLevel(float newZoomLevel); 122 123 /** zoom to by given ratio */ 124 void zoomInByRatio(float zoomRatio); 125 126} 127 128