Back to project page Save-the-Planet.
The source code is released under:
Copyright (c) 2002 JSON.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software ...
If you think the Android project Save-the-Planet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.karolmajta.stp.views; //from w ww .java 2 s . c o m import com.karolmajta.stp.exception.UnboundViewException; import processing.core.PApplet; /** * Abstract class for creating specialized views for concrete models. * Makes given Model instance accessible via protected model field. * * @author Karol * * @param <Model> Model this View will draw */ public abstract class View<Model> implements IDrawable<Model> { private boolean visible; protected Model model; public View() { this.visible = true; } @Override public final void bindModel(Model model) { this.model = model; } @Override public final void draw(PApplet p) throws UnboundViewException { if(model == null) { throw new UnboundViewException(); } if(visible){ onDraw(p); } } @Override public final void setVisible(boolean flag) { visible = flag; } @Override public final boolean isVisible() { return visible; } /** * Protected field model referencing object bound with * {@link View#bindModel(Object)} can be used inside this method. * @param p */ protected abstract void onDraw(PApplet p); }