public void mouseReleased(MouseEvent e) {
    if (e.isPopupTrigger())
    {
	MyPopupMenu.show(this,e.getX(),e.getY());
        return;
    }
    if (ImgDragStarted)
        ImgDragStarted=false;
    
    if (myPanel.DraggedMarker != null)  // successfully finished dragging
    {
            my3ddata.UpdateMarker(myPanel.DraggedMarker);  // Just in case the COI shall be used
            myPanel.DraggedMarker = null;
            repaint();
            updateothers(xprev,yprev);
            label.CoordsChanged();
            return;
    }

    if (! e.isControlDown())
        { ROIMoveStarted=false;ROIMoveDX=0;ROIMoveDY=0;repaint();}
    
    if (ROIMoveStarted & e.isControlDown())  // finalize
    {
            my3ddata.MoveROI(ROIMoveDX,ROIMoveDY,DimNr);
            ROIMoveStarted=false;
            ROIMoveDX=0;
            ROIMoveDY=0;
            LROIs=-1;
            //repaint();
            UpdateAll();
            return;
    }
    
    int SizeX = otherCanvas1.MaxPos-1;
    int SizeY = otherCanvas2.MaxPos-1;
    if (myPanel.ROIstarted)
    {
        otherCanvas1.ROIe = (int) XFromMouse(e.getX());
        otherCanvas2.ROIe = (int) YFromMouse(e.getY());
        if ((otherCanvas1.ROIe == otherCanvas1.ROIs) && (otherCanvas2.ROIe == otherCanvas2.ROIs))  // delete the ROI
        {
            my3ddata.TakeROI(0,0,SizeX,SizeY,DimNr);
            otherCanvas1.ROIs=0;otherCanvas1.ROIe=otherCanvas1.MaxPos-1;
            otherCanvas2.ROIs=0;otherCanvas2.ROIe=otherCanvas2.MaxPos-1;
            ROIs=0;ROIe=SizeX;
            UpdateAll();
        }
        else if (true) // ((otherCanvas1.ROIe >= otherCanvas1.ROIs) && (otherCanvas2.ROIe >= otherCanvas2.ROIs))
            {
                my3ddata.TakeROI(otherCanvas1.ROIs,otherCanvas2.ROIs,otherCanvas1.ROIe,otherCanvas2.ROIe,DimNr);
                UpdateAll();
            }
    }
    /*if (LineROIStarted)
    {
        otherCanvas1.LROIe = (int) XFromMouse(e.getX());
        otherCanvas2.LROIe = (int) YFromMouse(e.getY());
        if ((otherCanvas1.LROIe == otherCanvas1.LROIs) && (otherCanvas2.LROIe == otherCanvas2.LROIs))  // delete the ROI
        {
            my3ddata.ClearLineROIs();
            PlanesXs.removeAllElements();PlanesYs.removeAllElements();PlanesXe.removeAllElements();PlanesYe.removeAllElements();
            otherCanvas1.PlanesXs.removeAllElements();otherCanvas1.PlanesYs.removeAllElements();otherCanvas1.PlanesXe.removeAllElements();otherCanvas1.PlanesYe.removeAllElements();
            otherCanvas2.PlanesXs.removeAllElements();otherCanvas2.PlanesYs.removeAllElements();otherCanvas2.PlanesXe.removeAllElements();otherCanvas2.PlanesYe.removeAllElements();
        }
        else
        {
            my3ddata.TakeLineROI(otherCanvas1.LROIs,otherCanvas2.LROIs,otherCanvas1.LROIe,otherCanvas2.LROIe,DimNr);
            PlanesXs.addElement(new Integer(otherCanvas1.LROIs));
            PlanesYs.addElement(new Integer(otherCanvas2.LROIs));
            PlanesXe.addElement(new Integer(otherCanvas1.LROIe));
            PlanesYe.addElement(new Integer(otherCanvas2.LROIe));
        }
        LineROIStarted=false;
    }*/
    myPanel.ROIstarted=false;
}