/*
* 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.render;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.render.BasicShapeAttributes;
import gov.nasa.worldwind.render.Material;
import java.awt.Color;
import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.Observable;
import java.util.logging.Logger;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedMlo;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShp;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShpDimOne;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShpDimOneLine;
import org.geoforge.mdldsp.event.render.wwd.GfrEvtMdlIdDspRndWwdEarthShpDimOneLine;
import org.geoforge.wrpbasprsdsp.render.wwd.GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseYes;
/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
abstract public class GfrRndSurfacePolylineWisYesMloAbs extends GfrRndSurfacePolylineWisYesAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrRndSurfacePolylineWisYesMloAbs.class.getName());
static
{
GfrRndSurfacePolylineWisYesMloAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
protected String _strIdParent_ = null;
public String getIdParentGtr() { return this._strIdParent_; }
protected GfrRndSurfacePolylineWisYesMloAbs(
PropertyChangeListener lstShouldRedraw,
String strId,
String strName,
List<Position> lstPosition,
String strIdParent)
throws Exception
{
super(lstShouldRedraw, strId, strName, lstPosition);
this._strIdParent_ = strIdParent;
setEnabledTooltipThis();
}
@Override
public void update(Observable obs, Object objEvt)
{
// beg display
if (objEvt instanceof GfrEvtMdlIdDspRndWwdEarthShpDimOneLine)
{
GfrEvtMdlIdDspRndWwdEarthShpDimOneLine evt = (GfrEvtMdlIdDspRndWwdEarthShpDimOneLine) objEvt;
String strId = evt.getId();
if (strId.compareTo(this._strIdParent_) != 0)
return;
Object objWhat = evt.getWhat();
if (objWhat == EnuEvtDspRndWwdEarthShp.TOOLTIP)
{
Boolean boo = (Boolean) evt.getValue();
super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, boo.booleanValue());
// memo: no need to send event to redraw!
return;
}
if (objWhat == EnuEvtDspRndWwdEarthShpDimOne.COLOR)
{
Color col = (Color) evt.getValue();
BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
bsa.setOutlineMaterial(new Material(col));
this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
return;
}
if (objWhat == EnuEvtDspRndWwdEarthShpDimOne.TRANSPARENCY)
{
Float flo = (Float) evt.getValue();
float fltAlpha = flo.floatValue();
BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
bsa.setOutlineOpacity((double) fltAlpha);
this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
return;
}
if (objWhat == EnuEvtDspRndWwdEarthShpDimOneLine.THICKNESS)
{
Integer itg = (Integer) evt.getValue();
BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
bsa.setOutlineWidth(itg.doubleValue());
this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
return;
}
return;
}
// end display
// beg data
if (objEvt instanceof GfrEvtMdlIdDatRenamedMlo)
{
GfrEvtMdlIdDatRenamedMlo evt = (GfrEvtMdlIdDatRenamedMlo) objEvt;
String strIdChild = evt.getId();
if (strIdChild.compareTo(super._strId) != 0)
return;
String strNameNewChild = evt.getValueNew();
super.setValue(gov.nasa.worldwind.avlist.AVKey.DISPLAY_NAME, strNameNewChild);
// memo: no need to redraw, coz of just handling toolTip
return;
}
// end data
}
@Override
public void setAttributesThis() throws Exception
{
BasicShapeAttributes bsa = new BasicShapeAttributes();
bsa.setDrawOutline(true);
double dblWidthOut = (double) GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseYes.getInstance().getThickness(this._strIdParent_);
bsa.setOutlineWidth(dblWidthOut);
Color colRgbOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseYes.getInstance().getColor(this._strIdParent_);
bsa.setOutlineMaterial(new Material(colRgbOut));
float fltAlphaOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseYes.getInstance().getTransparency(this._strIdParent_);
bsa.setOutlineOpacity((double) fltAlphaOut);
super.setAttributes(bsa);
}
@Override
public void setEnabledTooltipThis() throws Exception
{
boolean blnIsToolTip = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseYes.getInstance().isTooltip(this._strIdParent_);
super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, blnIsToolTip);
}
}