org.eclipse.draw2d.MouseEvent Java Examples

The following examples show how to use org.eclipse.draw2d.MouseEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
	if (e.button == 1) {
		if (firstClick) {
			firstClick = false;
			TimerTask timerTask = new TimerTask() {

				@Override
				public void run() {
					firstClick = true;
				}

			};
			Timer timer = new Timer();
			timer.schedule(timerTask, 250);
		} else {
			ChangeStateCommand command = new ChangeStateCommand(node);
			node.parent().editor.getCommandStack().execute(command);
		}
	}
}
 
Example #2
Source File: IntensityGraphFigure.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void mouseDoubleClicked(MouseEvent me) {
	if(me.button !=1)
		return;
	if(xAxisRange !=null)
		xAxis.setRange(xAxisRange);
	if(yAxisRange != null)
		yAxis.setRange(yAxisRange);
	if(originalCrop != null){
		setCropLeft(originalCrop.x);
		setCropTop(originalCrop.y);
		setCropRight(originalCrop.width);
		setCropBottom(originalCrop.height);
		graphArea.repaint();
	}
		
}
 
Example #3
Source File: DetailAreaListener.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void mouseReleased(MouseEvent me) {
	if (!fDragged) {
		final IFigure figureUnderCursor = fFigure.findFigureAt(me.x, me.y);

		if (figureUnderCursor instanceof EventFigure) {
			// selection
			RootFigure.getRootFigure(fFigure).setSelection((EventFigure) figureUnderCursor);
		} else {
			// create cursor
			final long eventTime = RootFigure.getTimeViewDetails(fFigure).screenOffsetToEventTime(me.x);
			RootFigure.getRootFigure(fFigure).createCursor(eventTime);
		}
	}

	if (fLocation != null) {
		fLocation = null;
		me.consume();
	}
}
 
Example #4
Source File: ScaledSliderFigure.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void mousePressed(MouseEvent me) {
	if(me.button != 1)
		return;
	armed = true;
	double valuePosition = 
		((LinearScale)scale).getValuePosition(getCoercedValue(), false);
	start = new Point(
			horizontal? valuePosition: 0, 
			horizontal ? 0 : valuePosition);
	label.setVisible(true);
	if(!ScaledSliderFigure.this.hasFocus()){
		ScaledSliderFigure.this.requestFocus();
	}
	me.consume();
	
}
 
Example #5
Source File: EntityFigureListener.java    From JDeodorant with MIT License 5 votes vote down vote up
public void mouseEntered(MouseEvent me) {

		List<JConnection> connections = figure.getOutgoingConnections();
		for(JConnection connection: connections){

			connection.setLineWidth(3);
			Label l = connection.getLabel();

			if(l != null){

				//String fontStyle = "Arial";
				ConnectionEndpointLocator locator = new ConnectionEndpointLocator(connection, true);

				if(connection.isWrite()){
					locator.setUDistance(95);
					locator.setVDistance(0);
				} else{
					locator.setUDistance(42);
					locator.setVDistance(0);
				}


				//l.setFont(new Font(null, fontStyle, 14 , SWT.BOLD));
				l.setFont(DecorationConstants.highlightFont);

				connection.add(l, locator);
			}

			PolygonDecoration decoration = new PolygonDecoration();
			decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP);
			decoration.setSize(20, 20);
			decoration.setBackgroundColor(connection.getForegroundColor());
			connection.setTargetDecoration(decoration);
		}
	}
 
Example #6
Source File: Axis.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseExited(final MouseEvent me) {
	// Treat like releasing the button to stop zoomIn/Out timer
	switch (zoomType) {
	case ZOOM_IN:
	case ZOOM_IN_HORIZONTALLY:
	case ZOOM_IN_VERTICALLY:
	case ZOOM_OUT:
	case ZOOM_OUT_HORIZONTALLY:
	case ZOOM_OUT_VERTICALLY:
		mouseReleased(me);
	default:
	}
}
 
Example #7
Source File: MultipleGuideHandle.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void mouseExited( MouseEvent me )
{
	if ( showSource.getParent( ) != null )
	{
		showSource.getParent( ).remove( showSource );
	}
	super.mouseExited( me );
}
 
Example #8
Source File: OverviewSelectionMover.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent me) {
	if (fLocation != null) {
		fLocation = null;
		me.consume();
	}

	fFigure.removeMouseMotionListener(this);
}
 
Example #9
Source File: ROIFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent me) {
	if(armed){
		armed = false;
		updateROIBounds(me);
		fireROIUpdated();
		me.consume();
	}
}
 
Example #10
Source File: AbstractSwitchLaneSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void mousePressed(MouseEvent me) {
	try {
		IUndoableOperation c = getSwitchLaneCommand(type);
		OperationHistoryFactory.getOperationHistory().execute(c,null,null);
		me.consume();
		refresh();
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
}
 
Example #11
Source File: KnobFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent me) {
					if (!armed) 
						return;
					 
					PolarPoint currentPP = 
						PolarPoint.point2PolarPoint(pole, me.getLocation());
					//rotate axis to endAngle
					currentPP.rotateAxis(((RoundScale)scale).getEndAngle(), false);
					
					//coerce currentPP to min or max
					if(currentPP.theta * 180.0/Math.PI > (((RoundScale)scale).getLengthInDegrees())) {
						if(Math.abs(((RoundScale)scale).getValuePosition(getCoercedValue(), true)-
							(((RoundScale)scale).getLengthInDegrees())) < ((RoundScale)scale).getLengthInDegrees()/2.0)
							currentPP.theta = ((RoundScale)scale).getLengthInDegrees() * Math.PI/180.0;
						else
							currentPP.theta = 0;
					}
						
					double difference = currentPP.theta * 180.0/Math.PI - oldValuePosition;	
					double valueChange = calcValueChange(difference, value);
					if(increment <= 0 || Math.abs(valueChange) > increment/2.0) {
//						manualSetValue = true;
						if(increment > 0)
							manualSetValue(value + increment * Math.round(valueChange/increment));		
						else 
							manualSetValue(value + valueChange);
											
						oldValuePosition = ((RoundScale)scale).getValuePosition(
							value, true);						
						fireManualValueChange(value);
						KnobFigure.this.revalidate();
						KnobFigure.this.repaint();					
					}
					me.consume();					
				}
 
Example #12
Source File: ROIFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param me
 */
protected void updateROIBounds(MouseEvent me) {
	int dx = me.x - start.x;
	int dy = me.y - start.y;
	RECT_SINGLETON.setBounds(startROIBounds.x + dx, startROIBounds.y + dy,
			startROIBounds.width, startROIBounds.height);
	setROIGeoBounds(RECT_SINGLETON.x, RECT_SINGLETON.y,
				RECT_SINGLETON.width, RECT_SINGLETON.height);
}
 
Example #13
Source File: DetailAreaListener.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent me) {
	fDragged = false;
	fLocation = me.getLocation();

	me.consume();
}
 
Example #14
Source File: OverviewSelector.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent me) {
	if (me.button == 1) {
		System.out.println("Select: " + me.x);
		final TimeBaseConverter timeViewDetails = RootFigure.getTimeViewDetails(fFigure);
		final Timing eventTime = timeViewDetails.overviewCoordinatesToEventTime(new Timing(me.x - fFigure.getParent().getInsets().left, 0));

		timeViewDetails.revealEvent(eventTime);
	}
}
 
Example #15
Source File: UpdateSizePoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent me) {
    try {

        IFigure  f = ((CustomMainProcessEditPart) poolEditPart.getParent()).getFigure() ;
        IFigure p = f ;
        while(!(p instanceof Viewport)){
            p = p.getParent();
        }

        int y = ((Viewport)p).getVerticalRangeModel().getValue() ;
        int x = ((Viewport)p).getHorizontalRangeModel().getValue() ;


        IUndoableOperation c = new UpdatePoolSizeCommand(poolEditPart, type);
        OperationHistoryFactory.getOperationHistory().execute(c,null,null);
        me.consume();


        poolEditPart.getViewer().setSelection(new StructuredSelection(poolEditPart));
        refresh();
        poolEditPart.getViewer().setSelection(new StructuredSelection(getHost()));

        if(type.equals(ADD_RIGHT)){
            ((Viewport)p).setHorizontalLocation(x+150);
        }

        ((Viewport)p).setVerticalLocation(y);


    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
 
Example #16
Source File: IntensityGraphFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent me) {
	if(armed && end != null && start != null){
		zoom();				
	}
	armed = false;
	end = null; 
	start = null;			
}
 
Example #17
Source File: KnobFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent me) {
	if(me.button != 1)
		return;
	armed = true;
	pole = scale.getBounds().getCenter();										
	startPP = PolarPoint.point2PolarPoint(pole, bounds.getCenter());
	//rotate axis to endAngle
	startPP.rotateAxis(((RoundScale)scale).getEndAngle(), false);
	
	
	oldValuePosition = ((RoundScale)scale).getValuePosition(
			getCoercedValue(), true);
	me.consume();
}
 
Example #18
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseDragged(MouseEvent me) {
	x0 = me.getLocation().x - currentPosition.x;
	y0 = me.getLocation().y - currentPosition.y;
	knowX0Y0 = true;
	updatedxdyFromX0Y0();
	Annotation.this.revalidate();
	Annotation.this.repaint();
	me.consume();
}
 
Example #19
Source File: CursorMover.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseExited(MouseEvent me) {
	final ITimelineStyleProvider styleProvider = RootFigure.getRootFigure(fFigure).getStyleProvider();
	fFigure.setForegroundColor(styleProvider.getCursorColor());
	fFigure.setBackgroundColor(styleProvider.getCursorColor());

	hideCursorTimings();
}
 
Example #20
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent me) {
	command.setAfterMovingDxDy(dx, dy);
	xyGraph.getOperationsManager().addCommand(command);
	infoLabelArmed = false;
	Annotation.this.revalidate();
	Annotation.this.repaint();
	me.consume();
}
 
Example #21
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseDragged(MouseEvent me) {
	Point mouseLocation = new Point(horizontalMoveable ? me.getLocation().x : currentPosition.x,
			verticalMoveable ? me.getLocation().y : currentPosition.y);
	// free
	if (trace == null) {
		setCurrentPosition(mouseLocation, me.getState() == (SWT.BUTTON1 | SWT.CONTROL));
	} else { // snap to trace
				// double tempX =
				// xAxis.getPositionValue(me.getLocation().x, false);
				// double tempY =
				// yAxis.getPositionValue(me.getLocation().y, false);
		ISample tempSample = null;
		double minD = Double.POSITIVE_INFINITY;
		double d;
		for (ISample s : trace.getHotSampleList()) {
			d = Math.sqrt(Math.pow(xAxis.getValuePosition(s.getXValue(), false) - mouseLocation.x, 2)
					+ Math.pow(yAxis.getValuePosition(s.getYValue(), false) - mouseLocation.y, 2));
			if (minD > d) {
				minD = d;
				tempSample = s;
			}
		}
		if (tempSample != null && currentSnappedSample != tempSample)
			setCurrentSnappedSample(tempSample, me.getState() == (SWT.BUTTON1 | SWT.CONTROL));
		else if (tempSample == null) {
			setCurrentPosition(mouseLocation, me.getState() == (SWT.BUTTON1 | SWT.CONTROL));
			pointerDragged = true;
		}

	}
	me.consume();
}
 
Example #22
Source File: ListBandControlFigure.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void mousePressed( MouseEvent me )
{
	state = !state;
	IFigure parent = this;
	while ( ( parent = parent.getParent( ) ) != null )
	{
		if ( parent instanceof ReportShowFigure )
		{
			( (ReportShowFigure) parent ).setShowing( state );
			getOwner( ).markDirty( true );
			break;
		}
	}

}
 
Example #23
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent me) {
	command = new MovingAnnotationCommand(Annotation.this);
	if (isFree())
		command.setBeforeMovePosition(currentPosition);
	else
		command.setBeforeMoveSnappedSample(currentSnappedSample);
	command.setBeforeDxDy(dx, dy);
	me.consume(); // it must be consumed to make dragging smoothly.
}
 
Example #24
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent me) {
	if (command != null) {
		if (isFree())
			command.setAfterMovePosition(currentPosition);
		else
			command.setAfterMoveSnappedSample(currentSnappedSample);
		command.setAfterDxDy(dx, dy);
		xyGraph.getOperationsManager().addCommand(command);
	}

}
 
Example #25
Source File: RailroadSelectionProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void setSelection(MouseEvent me, boolean isDoubleClick) {
	IFigure selectedFigure = view.findFigureAt(me.getLocation());
	while (selectedFigure != null && !(selectedFigure instanceof IEObjectReferer))
		selectedFigure = selectedFigure.getParent();
	if (selectedFigure != null) {
		setSelection(new StructuredSelection(selectedFigure), isDoubleClick);
	}
}
 
Example #26
Source File: PlotArea.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseExited(final MouseEvent me) {
	fireMouseExited(me);
	// Treat like releasing the button to stop zoomIn/Out timer
	switch (zoomType) {
	case ZOOM_IN:
	case ZOOM_IN_HORIZONTALLY:
	case ZOOM_IN_VERTICALLY:
	case ZOOM_OUT:
	case ZOOM_OUT_HORIZONTALLY:
	case ZOOM_OUT_VERTICALLY:
		mouseReleased(me);
	default:
	}
}
 
Example #27
Source File: SwitchPoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void mousePressed(MouseEvent me) {
	try {
		IUndoableOperation c = new SwitchPoolOrderCommand((IGraphicalEditPart) getHost(), type);
		OperationHistoryFactory.getOperationHistory().execute(c,null,null);
		me.consume();
		refresh();
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
}
 
Example #28
Source File: ActivityNameCursorMouseMotionListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseHover(MouseEvent me) {
    final Figure source = (Figure) me.getSource();
    if (editPart.getSelected() == EditPart.SELECTED_PRIMARY) {
        source.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
    } else {
        source.setCursor(Pics.getOpenedHandCursor());
    }
}
 
Example #29
Source File: ActivityNameCursorMouseMotionListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseEntered(MouseEvent me) {
    final Figure source = (Figure) me.getSource();
    if (editPart.getSelected() == EditPart.SELECTED_PRIMARY) {
        source.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
    } else {
        source.setCursor(Pics.getOpenedHandCursor());
    }

}
 
Example #30
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void activate ( final String tag, final Shape shape )
{
    shape.addMouseListener ( new MouseListener.Stub () {

        @Override
        public void mouseReleased ( final MouseEvent me )
        {
            GenericLevelPresets.this.triggerAction ( tag );
        }
    } );
}