/*
* 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.Material;
import gov.nasa.worldwind.render.PointPlacemarkAttributes;
import java.awt.Color;
import java.beans.PropertyChangeListener;
import java.util.Observable;
import java.util.logging.Logger;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdl.event.GfrEvtMdlIdAbs;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedTlo;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShp;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShpDimOne;
import org.geoforge.mdldsp.event.render.wwd.GfrEvtMdlIdDspRndWwdEarthShpDimOnePoint;
import org.geoforge.wrpbasprsdsp.render.wwd.GfrWrpBasPrsDspPrjRndWwdEarthShpDimOnePointCircle;
/**
*
* @author bill
*/
abstract public class GfrRndPointPlacemarkCircleAbs extends GfrRndPointPlacemarkAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrRndPointPlacemarkCircleAbs.class.getName());
static
{
GfrRndPointPlacemarkCircleAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
private java.lang.Double _douScale_ = 7d; // default
protected GfrRndPointPlacemarkCircleAbs(
PropertyChangeListener lstShouldRedraw,
String strId,
String strName,
Position pos,
java.lang.Double dblScale)
throws Exception
{
super(lstShouldRedraw, strId, strName, pos);
this._douScale_ = dblScale;
setAttributesThis();
setEnabledTooltipThis();
}
@Override
public void setEnabledTooltipThis() throws Exception
{
boolean blnIsToolTip = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOnePointCircle.getInstance().isTooltip(this._strId);
super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, blnIsToolTip);
}
@Override
public void setAttributesThis() throws Exception
{
PointPlacemarkAttributes ppa = new PointPlacemarkAttributes();
Color colRgb = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOnePointCircle.getInstance().getColor(super._strId);
float fltAlpha = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOnePointCircle.getInstance().getTransparency(super._strId);
fltAlpha *=100;
fltAlpha *= 2.5;
int intAlpha = Math.round(fltAlpha);
Color col = new Color(colRgb.getRed(), colRgb.getGreen(), colRgb.getBlue(), intAlpha);
ppa.setLineMaterial(new Material(col));
ppa.setScale(this._douScale_);
ppa.setUsePointAsDefaultImage(true);
super.setAttributes(ppa);
}
@Override
public void update(Observable obs, Object objEvt)
{
// beg display
if (objEvt instanceof GfrEvtMdlIdDspRndWwdEarthShpDimOnePoint)
{
GfrEvtMdlIdDspRndWwdEarthShpDimOnePoint evt = (GfrEvtMdlIdDspRndWwdEarthShpDimOnePoint) objEvt;
String strId = evt.getId();
if (strId.compareTo(super._strId) != 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();
PointPlacemarkAttributes ppa = super.getAttributes();
ppa.setLineMaterial(new Material(col));
this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
return;
}
if (objWhat == EnuEvtDspRndWwdEarthShpDimOne.TRANSPARENCY)
{
Float flo = (Float) evt.getValue();
float fltAlpha = flo.floatValue();
fltAlpha *=100;
fltAlpha *= 2.55;
int intAlpha = Math.round(fltAlpha);
PointPlacemarkAttributes ppa = super.getAttributes();
Color colOld = ppa.getLineMaterial().getDiffuse();
Color colNew = new Color(colOld.getRed(), colOld.getGreen(), colOld.getBlue(), intAlpha);
ppa.setLineMaterial(new Material(colNew));
this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
return;
}
return;
}
// end display
// beg data
GfrEvtMdlIdAbs objId = (GfrEvtMdlIdAbs) objEvt;
String strIdEvt = objId.getId();
if (strIdEvt.compareTo(this._strId) != 0)
return;
if (objId instanceof GfrEvtMdlIdDatRenamedTlo)
{
GfrEvtMdlIdDatRenamedTlo objRename = (GfrEvtMdlIdDatRenamedTlo) objId;
super.setValue(gov.nasa.worldwind.avlist.AVKey.DISPLAY_NAME, objRename.getValueNew());
// memo: no need to redraw, coz of just handling toolTip
return;
}
// end data
}
}