Esempio n. 1
0
 /**
  * Sets the active layer of the track if the specified layer is one of the layers of the track.
  * Sets the active layer to null if the specified parameter is null. Does nothing if the specified
  * layer is not null and is not one of the layers of the track
  *
  * @param activeLayer the active layer to set
  */
 public void setActiveLayer(Layer<?> activeLayer) {
   Layer<?> oldLayer = getActiveLayer();
   if (activeLayer == null) {
     this.activeLayer = null;
   } else if (layers.contains(activeLayer)) {
     this.activeLayer = activeLayer;
   }
   // update the mouse listeners of the graphics panel
   if (oldLayer != activeLayer) {
     if (oldLayer != null) {
       if (oldLayer instanceof MouseMotionListener) {
         graphicsPanel.removeMouseMotionListener((MouseMotionListener) oldLayer);
       }
       if (oldLayer instanceof MouseListener) {
         graphicsPanel.removeMouseListener((MouseListener) oldLayer);
       }
       if (oldLayer instanceof MouseWheelListener) {
         graphicsPanel.removeMouseWheelListener((MouseWheelListener) oldLayer);
       }
     }
     if (activeLayer != null) {
       if (activeLayer instanceof MouseMotionListener) {
         graphicsPanel.addMouseMotionListener((MouseMotionListener) activeLayer);
       }
       if (activeLayer instanceof MouseListener) {
         graphicsPanel.addMouseListener((MouseListener) activeLayer);
       }
       if (activeLayer instanceof MouseWheelListener) {
         graphicsPanel.addMouseWheelListener((MouseWheelListener) activeLayer);
       }
     }
   }
 }
Esempio n. 2
0
 @Override
 public void intervalRemoved(ListDataEvent e) {
   // case where the active layer was removed
   if (!layers.contains(activeLayer)) {
     setActiveLayer(null);
   }
   updateGraphicsPanelDrawers();
   getScore().autorescaleScoreAxis();
 }
Esempio n. 3
0
 @Override
 public void contentsChanged(ListDataEvent e) {
   // case where the active layer was removed
   if (!layers.contains(activeLayer)) {
     setActiveLayer(null);
   }
   if ((activeLayer == null) && !layers.isEmpty()) {
     setActiveLayer(layers.getLayers()[0]);
   }
   updateGraphicsPanelDrawers();
   getScore().autorescaleScoreAxis();
 }