/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.worldwind.multiwindow.gfrsynchro;
import gov.nasa.worldwind.BasicModel;
import gov.nasa.worldwind.Model;
import gov.nasa.worldwind.globes.Earth;
import gov.nasa.worldwind.globes.Globe;
import gov.nasa.worldwind.layers.CompassLayer;
import gov.nasa.worldwind.layers.Earth.BMNGWMSLayer;
import gov.nasa.worldwind.layers.Earth.LandsatI3WMSLayer;
import gov.nasa.worldwind.layers.Layer;
import gov.nasa.worldwind.layers.LayerList;
import gov.nasa.worldwind.layers.StarsLayer;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
public class GfrMultiFrameSynchro
{
public static void main(String[] args)
{
try
{
// Create a Model for each window, starting with the Globe they share.
Globe earth = new Earth();
// Create layers that both World Windows can share.
Layer[] layers = new Layer[]
{
new StarsLayer(),
new CompassLayer(),
new BMNGWMSLayer(),
new LandsatI3WMSLayer(),
};
// Create two models and pass them the shared layers.
Model modelForWindowA = new BasicModel();
modelForWindowA.setGlobe(earth);
modelForWindowA.setLayers(new LayerList(layers));
// Create two frames and give each their own model.
GfrCanvasFrame frameA = new GfrCanvasFrame(null, modelForWindowA, "Frame A");
Model modelForWindowB = new BasicModel();
modelForWindowB.setGlobe(earth);
modelForWindowB.setLayers(new LayerList(layers));
// When creating the second frame, specify resource sharing with the first one.
GfrCanvasFrame frameB = new GfrCanvasFrame(frameA.getWwd(), modelForWindowB, "Frame B");
// Create two models and pass them the shared layers.
Model modelForWindowC = new BasicModel();
modelForWindowC.setGlobe(earth);
modelForWindowC.setLayers(new LayerList(layers));
// Create two frames and give each their own model.
GfrCanvasFrame frameC = new GfrCanvasFrame(null, modelForWindowC, "Frame C");
frameA.addSecondaryViewer(frameB);
frameA.addSecondaryViewer(frameC);
frameB.addSecondaryViewer(frameA);
frameB.addSecondaryViewer(frameC);
frameC.addSecondaryViewer(frameB);
frameC.addSecondaryViewer(frameA);
//*/
}
catch (Exception e)
{
e.printStackTrace();
}
}
}