/** * Updates the list of drawers registered to the graphics panel. There are one drawer per layer * including the background and foreground layers that need to be registered. */ private void updateGraphicsPanelDrawers() { if (layers == null) { // case where there is no other layer than the foreground and the background Drawer[] drawers = {backgroundLayer, foregroundLayer}; graphicsPanel.setDrawers(drawers); } else { // case where there are other layers Drawer[] drawers = new Drawer[layers.size() + 2]; drawers[0] = backgroundLayer; int i = 1; // we want to draw the layers in reverse order because the first layers // of the list should be on top for (int j = layers.size() - 1; j >= 0; j--) { Drawer currentDrawer = layers.getLayers()[j]; drawers[i] = currentDrawer; i++; } drawers[i] = foregroundLayer; graphicsPanel.setDrawers(drawers); } }
/** * Method used for serialization * * @param out * @throws IOException */ private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(SAVED_FORMAT_VERSION_NUMBER); out.writeInt(trackNumber); out.writeObject(backgroundLayer); out.writeObject(foregroundLayer); // write the number of layers if ((layers == null) || layers.isEmpty()) { out.writeInt(0); } else { out.writeInt(layers.size()); out.writeObject(layers); // make sure the active layer is not null if (activeLayer == null) { setActiveLayer(layers.getLayers()[0]); } out.writeObject(activeLayer); } out.writeObject(score); // save the height of the track out.writeInt(trackPanel.getHeight()); if (SAVED_FORMAT_VERSION_NUMBER >= 1) { out.writeObject(getName()); } }