code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
//Map - Stage
package {
import flash.display.Sprite;
public class Main extends Sprite{
private var enemies:Array;
private var heros:Array;
private var target:Target;
public function Main() {
target = new Target(stage.stageWidth,stage.stageHeight / 2);
addChild(target);
enemies = new Array();
for (var i:int = 0; i < 10; i++) {
var speed:Number = 2+Math.random() * 2;
var en:Enemy = new Enemy(target, speed);
en.Opposite = heros;
en.x = 0;
en.y = Math.random()*stage.stageHeight;
enemies.push(en);
addChild(en);
}
heros = new Array();
for (var ih:int = 0; ih < 2; ih++) {
var h:Hero = new Hero(ih);
h.Opposite = enemies;
h.x = stage.stageWidth/2 + 150 * ih;
h.y = stage.stageHeight / 2;
heros.push(h);
addChild(h);
}
}
}
}
| 108fantasy-tactics | trunk/Main.as | ActionScript | art | 887 |
//Enemy
package {
import flash.display.Sprite;
import flash.events.Event;
public class Enemy extends Role {
public function Enemy(t:Target, s:Number) {
Side = "EVIL";
target = t;
speed = s;
graphics.lineStyle(1, 0xffffff);
graphics.drawCircle(0, 0, 5);
addEventListener(Event.ENTER_FRAME, moveToTarget);
}
}
}
| 108fantasy-tactics | trunk/Enemy.as | ActionScript | art | 385 |
package com.blitzagency.xray.logger
{
import com.blitzagency.xray.logger.XrayLogger;
import com.blitzagency.xray.logger.Log;
public class XrayLog
{
private var logger:XrayLogger;
function XrayLog()
{
// CONSTRUCT
logger = XrayLogger.getInstance();
}
//public function debug(message:String, dump:*=""):void
public function debug(message:String, ...rest):void
{
if(rest.length == 0) logger.debug(new Log(message, null, XrayLogger.DEBUG));
for(var i:Number=0;i<rest.length;i++)
{
if(i > 0) message = "";
logger.debug(new Log(message, rest[i], XrayLogger.DEBUG));
}
}
public function info(message:String, ...rest):void
{
if(rest.length == 0) logger.info(new Log(message, null, XrayLogger.INFO));
for(var i:Number=0;i<rest.length;i++)
{
if(i > 0) message = "";
logger.info(new Log(message, rest[i], XrayLogger.INFO));
}
}
public function warn(message:String, ...rest):void
{
if(rest.length == 0) logger.warn(new Log(message, null, XrayLogger.WARN));
for(var i:Number=0;i<rest.length;i++)
{
if(i > 0) message = "";
logger.warn(new Log(message, rest[i], XrayLogger.WARN));
}
}
public function error(message:String, ...rest):void
{
if(rest.length == 0) logger.error(new Log(message, null, XrayLogger.ERROR));
for(var i:Number=0;i<rest.length;i++)
{
if(i > 0) message = "";
logger.error(new Log(message, rest[i], XrayLogger.ERROR));
}
}
public function fatal(message:String, ...rest):void
{
if(rest.length == 0) logger.fatal(new Log(message, null, XrayLogger.FATAL));
for(var i:Number=0;i<rest.length;i++)
{
if(i > 0) message = "";
logger.fatal(new Log(message, rest[i], XrayLogger.FATAL));
}
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/XrayLog.as | ActionScript | art | 1,759 |
package com.blitzagency.xray.logger.events
{
import flash.events.Event;
public class DebugEvent extends Event
{
public var obj:Object = new Object();
public function DebugEvent(type:String, bubbles:Boolean, cancelable:Boolean, p_obj:Object):void
{
super(type, bubbles, cancelable);
obj = p_obj;
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/events/DebugEvent.as | ActionScript | art | 334 |
package com.blitzagency.xray.logger.events
{
import flash.events.Event;
import flash.events.EventDispatcher;
import com.blitzagency.xray.logger.events.DebugEvent;
public class DebugDispatcher extends EventDispatcher
{
public static var TRACE:String = "trace";
public function sendEvent(eventName:String, obj:Object):void
{
dispatchEvent(new DebugEvent(DebugDispatcher.TRACE, false, false, obj));
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/events/DebugDispatcher.as | ActionScript | art | 446 |
package com.blitzagency.xray.logger
{
import com.blitzagency.xray.logger.XrayLogger;
import com.blitzagency.xray.logger.util.ObjectTools;
import com.blitzagency.xray.logger.Debug;
public class Log
{
private var message:String;
private var dump:Object;
private var level:Number;
private var classPackage:String;
private var caller:String = "";
/*
* I generate an error in the constructor as to force the debugger to give me the stackTrace
* Supposedly, this won't work in the regular player, and as of 8/28/2006, I haven't tried it ;)
*
*/
public function Log(p_message:String, p_dump:Object, p_level:Number, ...rest)
{
var err:LogError;
var nullArray:Array;
try
{
nullArray.push("bogus");
}
catch(e:Error)
{
err = new LogError("log");
}
finally
{
if(err.hasOwnProperty("getStackTrace"))
{
var str:String = err.getStackTrace();
//Debug.trace(err.getStackTrace());
setCaller(resolveCaller(str));
}else
{
setCaller("");
}
setMessage(p_message);
setDump(p_dump);
setLevel(p_level);
setClassPackage(p_dump);
}
}
public function setMessage(p_message:String):void
{
message = p_message;
}
public function setDump(p_dump:Object):void
{
dump = p_dump;
}
public function setLevel(p_level:Number):void
{
level = p_level;
}
public function getMessage():String
{
return message;
}
public function getDump():Object
{
return dump;
}
public function getLevel():Number
{
return level;
}
public function getClassPackage():String
{
return classPackage;
}
public function setClassPackage(obj:Object):void
{
//classPackage = ObjectTools.getFullClassPath(obj);
classPackage = ObjectTools.getImmediateClassPath(obj);
}
private function resolveCaller(str:String):String
{
var ary:Array = [];
//Debug.trace("resolveCaller", str);
try
{
str = str.split("\n").join("");
ary = str.split(" at ");
str = ary[3];
}catch(e:Error)
{
}finally
{
str = "";
}
return str;
}
public function setCaller(p_caller:String):void
{
caller = p_caller;
}
public function getCaller():String
{
return caller;
}
}
}
class LogError extends Error
{
public function LogError(message:String)
{
// constructor
super(message);
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/Log.as | ActionScript | art | 2,545 |
/**
* @author John Grden
*/
package com.blitzagency.xray.logger
{
import com.blitzagency.xray.logger.Log;
public interface Logger
{
function setLevel(p_level:Number = 0):void;
function debug(obj:Log):void;
function info(obj:Log):void;
function warn(obj:Log):void;
function error(obj:Log):void;
function fatal(obj:Log):void;
function log(message:String, caller:String, classPackage:String, level:Number, dump:Object=null):void;
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/Logger.as | ActionScript | art | 455 |
package com.blitzagency.xray.logger
{
import flash.events.EventDispatcher;
import com.blitzagency.xray.logger.Debug;
import com.blitzagency.xray.logger.Logger;
import com.blitzagency.xray.logger.Log;
import com.blitzagency.xray.logger.util.PropertyTools;
import com.blitzagency.xray.logger.util.ObjectTools;
import flash.utils.*;
import flash.events.KeyboardEvent;
/**
* @author John Grden
*/
public class XrayLogger extends EventDispatcher implements Logger
{
public static var DEBUG:Number = 0;
public static var INFO:Number = 1;
public static var WARN:Number = 2;
public static var ERROR:Number = 3;
public static var FATAL:Number = 4;
public static var NONE:Number = 5;
public static function resolveLevelAsName(p_level:Number):String
{
switch(p_level)
{
case 0:
return "debug";
break;
case 1:
return "info";
break;
case 2:
return "warn";
break;
case 3:
return "error";
break;
case 4:
return "fatal";
break;
default:
return "debug";
}
}
private static var _instance:XrayLogger = null;
private var level:Number = 0; // set to DEBUG by default
private var displayObjectRecursionDepth:Number = 3;
private var objectRecursionDepth:Number = 254;
private var indentation:Number = 0;
private var filters:Array = [];
public static function getInstance():XrayLogger
{
if(_instance == null)
{
_instance = new XrayLogger();
}
return _instance;
}
public function setDisplayClipRecursionDepth(p_recursionDepth:Number):void
{
displayObjectRecursionDepth = p_recursionDepth;
}
public function setObjectRecursionDepth(p_recursionDepth:Number):void
{
objectRecursionDepth = p_recursionDepth;
}
public function setIndentation(p_indentation:Number = 0):void
{
indentation = p_indentation;
}
public function setLevel(p_level:Number = 0):void
{
level = p_level;
}
public function setFilters(p_filters:Array):void
{
filters = p_filters;
}
public function debug(obj:Log):void
{
if(obj.getLevel() == level)
{
log(obj.getMessage(), obj.getCaller(), obj.getClassPackage(), 0, obj.getDump());
}
}
public function info(obj:Log):void
{
if(obj.getLevel() >= level)
{
log(obj.getMessage(), obj.getCaller(), obj.getClassPackage(), 1, obj.getDump());
}
}
public function warn(obj:Log):void
{
if(obj.getLevel() >= level)
{
log(obj.getMessage(), obj.getCaller(), obj.getClassPackage(), 2, obj.getDump());
}
}
public function error(obj:Log):void
{
if(obj.getLevel() >= level)
{
log(obj.getMessage(), obj.getCaller(), obj.getClassPackage(), 3, obj.getDump());
}
}
public function fatal(obj:Log):void
{
if(obj.getLevel() >= level)
{
log(obj.getMessage(), obj.getCaller(), obj.getClassPackage(), 4, obj.getDump());
}
}
/**
* Logs the {@code message} using the {@code Debug.trace} method if
* {@code traceObject} is turned off or if the {@code message} is of type
* {@code "string"}, {@code "number"}, {@code "boolean"}, {@code "undefined"} or
* {@code "null"} and using the {@code Debug.traceObject} method if neither of the
* above cases holds {@code true}.
*
* @param message the message to log
*/
public function log(message:String, caller:String, classPackage:String, level:Number, dump:Object=null):void
{
// add time stamp
var traceMessage:String = "(" + getTimer() + ") ";
if(classPackage.length > 0) traceMessage += caller + "\n";
traceMessage += message;
if(message.length > 0) Debug.trace(traceMessage, classPackage, level);
if(dump == null) return;
// check to see if dump is an object or not
var type:String = typeof(dump);
if (type == "string" || type == "number" || type == "boolean" || type == "undefined" || type == "null")
{
Debug.trace(dump, classPackage, level);
}else if(type == "xml")
{
Debug.trace(dump.toString(), classPackage, level);
}else
{
var objType:String = ObjectTools.getImmediateClassPath(dump);
if(objType == "Object" || objType == "Object.Array")
{
// regular object types like Objects and Arrays can go straight to Debug
Debug.traceObject(dump, objectRecursionDepth, indentation, classPackage, level);
}else
{
// if we have something like a sprite/movieclip/component etc, we'll get it's props first, then send to Debug
var obj:Object = PropertyTools.getProperties(dump);
Debug.traceObject(obj, displayObjectRecursionDepth, indentation, classPackage, level);
}
}
}
public function checkFilters():Boolean
{
if(filters.length == 0) return true;
for(var i:uint=0;i<filters.length;i++)
{
}
return true;
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/XrayLogger.as | ActionScript | art | 5,086 |
package com.blitzagency.xray.logger.util
{
import flash.utils.*;
public class PropertyTools
{
public static function getProperties(obj:Object):Array
{
var ary:Array = [];
try
{
var xmlDoc:XML = describeType(obj);
// loop the extendsClass nodes
for each(var item:XML in xmlDoc.variable)
{
var name:String = item.@name.toString();
var type:String = item.@type.toString();
var value:Object = obj[name] != null ? obj[name] : "";
ary.push({name:name, type:type, value:value});
//log.debug("my object", item.@type.toString());
}
}catch(e:Error)
{
}
// return the full path as dot separated
return ary;
}
private static function getVariables():void
{
}
private static function getMethods():void
{
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/util/PropertyTools.as | ActionScript | art | 829 |
package com.blitzagency.xray.logger.util
{
import flash.utils.*;
import com.blitzagency.xray.logger.XrayLog;
public class ObjectTools
{
private static var log:XrayLog = new XrayLog();
public static function getFullClassPath(obj:Object):String
{
var xmlDoc:XML = describeType(obj);
var ary:Array = [];
// add the className of the actual object
var className:String = getQualifiedClassName(obj);
className = className.indexOf("::") > -1 ? className.split("::").join(".") : className;
ary.push(className);
// loop the extendsClass nodes
for each(var item:XML in xmlDoc.extendsClass)
{
var extClass:String = item.@type.toString().indexOf("::") > -1 ? item.@type.toString().split("::")[1] : item.@type.toString();
ary.push(extClass);
}
// return the full path as dot separated
return ary.join(".");
}
public static function getImmediateClassPath(obj:Object):String
{
var className:String = getQualifiedClassName(obj);
var superClassName:String = getQualifiedSuperclassName(obj);
className = className.indexOf("::") > -1 ? className.split("::").join(".") : className;
if(superClassName == null) return className;
superClassName = superClassName.indexOf("::") > -1 ? superClassName.split("::").join(".") : superClassName;
return superClassName + "." + className;
}
public function resolveBaseType(obj:Object):String
{
return "";
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/util/ObjectTools.as | ActionScript | art | 1,460 |
package com.blitzagency.xray.logger
{
/*
Debug class for use with bit-101 Flash Debug Panel
See www.bit-101.com/DebugPanel
This work is licensed under a Creative Commons Attribution 2.5 License.
See http://creativecommons.org/licenses/by/2.5/
Authors: Keith Peters and Tim Walling
www.bit-101.com
www.timwalling.com
Modified for Xray:
John Grden
neoRiley@gmail.com
www.osflash.org/xray
*/
import flash.utils.*;
import com.blitzagency.xray.logger.events.DebugDispatcher;
import flash.net.LocalConnection;
import flash.events.StatusEvent;
public class Debug
{
private static var xrayLC:LocalConnection;
private static var connected:Boolean = false;
private static var ed:DebugDispatcher = new DebugDispatcher();;
//private static var initialized:Boolean = initialize();
private static function initialize():Boolean
{
ed = new DebugDispatcher();
return true;
}
private static function makeConnection():void
{
var err:LogError;
xrayLC = new LocalConnection();
xrayLC.addEventListener("status", statusHandler);
xrayLC.allowDomain("*");
try
{
xrayLC.connect("_xray_standAlone_debug" + getTimer());
connected = true;
}
catch (e:Error)
{
err = new LogError("log");
//xrayLC.close();
setTimeout(makeConnection, 1000);
}
finally
{
}
}
private static function statusHandler(event:StatusEvent):void
{
if(event.code == null && event.level == "error" && connected)
{
connected = false;
}else
{
if(event.level == "status" && event.code == null)
{
connected = true;
}
}
}
public static function addEventListener(type:String, listener:Function):void
{
ed.addEventListener(type, listener);
}
/**
* Traces any value to the debug panel, with an optional message level.
* @param pMsg The value to trace.
* @param pLvl Optional. The level for this message. Values are 0 through 4, or Debug.Debug, Debug.INFO, Debug.WARN, Debug.ERROR, Debug.FATAL.
*/
public static function trace(pMsg:Object, pPackage:String = "", pLevel:Number = 0):void
{
// trace to the Flash IDE output window
ed.sendEvent(DebugDispatcher.TRACE, {message:pMsg, classPackage:pPackage});
//trace(pMsg);
if(!connected)
{
makeConnection();
}
if(connected)
{
try
{
var msg:String = String(pMsg).length >= 39995 ? String(pMsg).substr(0, 39995) + "..." : String(pMsg);
xrayLC.send("_xray_view_conn", "setTrace", msg, pLevel, pPackage);
}catch (e:LogError)
{
LogError("No Xray Interface running");
}
}
}
/**
* Recursively traces an object's value to the debug panel.
* @param o The object to trace.
* @param pRecurseDepth Optional. How many levels deep to recursively trace. Defaults to 0, which traces only the top level value.
* @param pIndent Optional. Number of spaces to indent each new level of recursion.
* @param pPackage - passed in via XrayLogger. Package info sent along to Xray's interface for package filtering
*/
public static function traceObject(o:Object, pRecurseDepth:Number = 254, pIndent:Number = 0, pPackage:String = "", pLevel:Number = 0):void
{
try
{
var recurseDepth:Number = pRecurseDepth;
var indent:Number = pIndent;
for (var prop:String in o)
{
var lead:String = "";
for (var i:Number=0; i<indent; i++)
{
lead += " ";
}
var obj:String = o[prop].toString();
if (o[prop] is Array)
{
obj = "[Array]";
}
if (obj == "[object Object]")
{
obj = "[Object]";
}
Debug.trace(lead + prop + ": " + obj, pPackage, pLevel);
if (recurseDepth > 0)
{
Debug.traceObject(o[prop], recurseDepth-1, indent+1, pPackage, pLevel);
}
}
}catch(e:Error)
{
//
}
}
}
}
class LogError extends Error
{
public function LogError(message:String)
{
// constructor
super(message);
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/logger/Debug.as | ActionScript | art | 4,163 |
package com.blitzagency.xray.util
{
import flash.net.SharedObject;
import mx.core.Application;
public class LSOUserPreferences
{
// Public Properties
public static var app:Object = mx.core.Application.application;
public static var loaded:Boolean = false;
public static var persistent:Boolean = true;
// Private Properties
private static var preferences:Object = {};
private static var storedObject:SharedObject;
// Retrieve Preference
public static function getPreference(p_key:String):*
{
var r:* = preferences[p_key] != undefined ? preferences[p_key] : null;
return r
}
public static function getAllPreferences():Object
{
return preferences;
}
// Set Local/LSO Preference
public static function setPreference(p_key:String, p_value:Object, p_persistent:Boolean):void
{
preferences[p_key] = p_value;
// Optionally save to LSO
if (p_persistent)
{
storedObject.data[p_key] = p_value;
var r:String = storedObject.flush();
var m:String;
//app.output.text += "writing SO :: " + r + "\n";
switch (r)
{
case "pending":
//app.output.text += "case pending \n";
m = "Flush is pending, waiting on user interaction";
break;
case true:
//app.output.text += "case true \n";
m = "Flush was successful. Requested Storage Space Approved";
break;
case false:
//app.output.text += "case false \n";
m = "Flush failed. User denied request for additional space.";
break;
}
}
}
// Load from LSO for now
public static function load(p_path:String):void
{
storedObject = SharedObject.getLocal("userPreferences" + p_path, "/");
for (var i:String in storedObject.data)
{
preferences[i] = storedObject.data[i];
}
loaded = true;
}
// Clear LSO and reset preferences
public static function clear():void
{
storedObject.clear();
storedObject.flush();
storedObject = null;
preferences = {};
}
}
} | 108fantasy-tactics | trunk/com/blitzagency/xray/util/LSOUserPreferences.as | ActionScript | art | 2,101 |
//Role
package {
import flash.display.Sprite;
import flash.events.Event;
public class Role extends Sprite {
protected var contact:int = 10;
protected var field:int = 35;
protected var target:Sprite;
protected var dir:Number;
protected var speed:Number;
protected var vx:Number;
protected var vy:Number;
protected var dX:int;
protected var dY:int;
public var Id:int;
protected var Side:String;
public var Opposite:Array;
protected var Lv:int;
protected var Hp:int;
protected var Mp:int;
public function Role() {
}
protected function moveToTarget(e:Event):void {
if (target) {
dX = target.x - x;
dY = target.y - y;
}
if (Math.abs(dY) < contact && Math.abs(dX) < contact) {
vx = vy = 0;
if (Side == "GOOD") killTarget(target);
removeEventListener(Event.ENTER_FRAME, moveToTarget);
addEventListener(Event.ENTER_FRAME, seekTarget);
}
else{
dir = Math.atan2(dY, dX);
vx = Math.cos(dir) * speed;
vy = Math.sin(dir) * speed;
x += vx;
y += vy;
}
}
protected function seekTarget(e:Event):void {
if (!target) {
for (var i:int = 0; i < Opposite.length; i++) {
dX = Opposite[i].x - x;
dY = Opposite[i].y - y;
if (Math.abs(dX) < field && Math.abs(dY) < field) {
Opposite[i].setTarget(this);
setTarget(Opposite[i]);
}
}
}
else {
trace("END SEEKING TARGET");
removeEventListener(Event.ENTER_FRAME, seekTarget);
addEventListener(Event.ENTER_FRAME, moveToTarget);
}
}
protected function setTarget(t:Sprite):void {
//TODO: multiple targets to implement...
target = t;
}
protected function killTarget(t:Sprite):void {
if (target == t) {
target.visible = false;
target = null;
removeEventListener(Event.ENTER_FRAME, moveToTarget);
addEventListener(Event.ENTER_FRAME, seekTarget);
}
}
}
}
| 108fantasy-tactics | trunk/Role.as | ActionScript | art | 1,991 |
// Copyright © 2006. Adobe Systems Incorporated. All Rights Reserved.
package fl.data {
/**
* The SimpleCollectionItem class defines a single item in an inspectable
* property that represents a data provider. A SimpleCollectionItem object
* is a collection list item that contains only <code>label</code> and
* <code>data</code> properties, for example, a ComboBox or List component.
*
* @internal Is this revised description correct?
* @adobe [LM} Yes, its ok.
*
* @includeExample examples/SimpleCollectionItemExample.as
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
dynamic public class SimpleCollectionItem {
[Inspectable()]
/**
* The label property of the object.
*
* The default value is <code>label(<em>n</em>)</code>, where <em>n</em> is the ordinal index.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public var label:String;
[Inspectable()]
/**
* The data property of the object.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public var data:String;
/**
* Creates a new SimpleCollectionItem object.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function SimpleCollectionItem() {}
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function toString():String {
return "[SimpleCollectionItem: "+label+","+data+"]";
}
}
} | 108fantasy-tactics | trunk/fl/data/SimpleCollectionItem.as | ActionScript | art | 1,637 |
package fl.data {
dynamic public class SimpleDataProvider extends Object {
public var dataProvider:Array;
public function SimpleDataProvider() {
dataProvider = [];
}
public function addItem(item:Object):void {
dataProvider.push(item);
}
public function getItemAt(index:uint):Object {
return dataProvider[index];
}
public function get length():uint {
return dataProvider.length;
}
public function toString():String {
return "[SimpleDataProvider (" + dataProvider.join(",") + ")]";
}
}
} | 108fantasy-tactics | trunk/fl/data/SimpleDataProvider.as | ActionScript | art | 580 |
/**
* @private
*/
// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved.
package fl.livepreview {
import flash.display.*;
import flash.external.*;
import flash.utils.*;
import flash.events.KeyboardEvent;
/**
* The LivePreviewParent class provides the timeline for a SWC file
* or for a compiled clip that is being exported when ActionScript 3.0
* is selected.
*
* <p>When a property is set on a component instance or when a component
* instance is resized on the Stage, Flash makes calls to the methods of
* this class, which in turn call methods in your component code to set
* the properties and to resize the component.</p>
*
* <p>In cases where your component must implement a specific action when
* it is in live preview mode, use the following code to test for live preview
* mode:</p>
*
* <listing>var isLivePreview:Boolean = (parent != null && getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent");</listing>
*
* <p>The LivePreviewParent class supports the definition of a <code>setSize()</code>
* method that uses <code>width</code> and <code>height</code> values to resize
* a component. If you do not define a <code>setSize()</code> method, this object
* sets the <code>width</code> and <code>height</code> properties individually.</p>
*
* <p>You can also use this class to create a custom live preview SWF file without
* creating a SWC file; however, it is probably easier to create a component live
* preview file by:</p>
* <ul>
* <li>Exporting your component as a SWC file.</li>
* <li>Changing the .swc file extension to .zip.</li>
* <li>Extracting the SWF file within the ZIP file.</li>
* </ul>
* <p>To create a component live preview file in this way, follow these steps:</p>
* <ol>
* <li>Create a new Flash document.</li>
* <li>Set its document class to fl.livepreview.LivePreviewParent.</li>
* <li>Drag your component to the Stage and position it to x and y coordinates of 0.</li>
* <li>Check to ensure that the component parameters remain at their default settings.
* This should be the case if you drag the component from the Library panel or from the
* Components panel.</li>
* <li>Select Modify > Document from the main menu and, for the Match option, click Contents.</li>
* <li>Click OK.</li>
* <li>Publish the file to see the resulting SWF file as a custom live preview
* SWF file.</li>
* <li>Right-click the asset in the Library panel and select Component Definition from the context menu.</li>
* <li>The Component Definition dialog box allows you to specify a custom live preview
* SWF file for a component.</li>
* </ol>
*
* <p>In some cases, you may want to have a custom live preview SWF file that is
* completely different from your component. See the live preview of the fl.containers.UILoader
* component for such an example. This live preview does not use the properties of UILoader,
* nor does it implement getter and setter functions for these properties. It does, however,
* implement a <code>setSize()</code> method that uses <code>width</code> and <code>height</code>
* parameters to draw the component at the new size.</p>
*
* @internal for example, you can look at the code UILoader live preview as and fla at
* //depot/main/frameworks/UIControls_BLAZE/fla/...
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public class LivePreviewParent extends MovieClip {
/**
* The component instance.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public var myInstance:DisplayObject;
/**
* Initializes the scale and align modes of the Stage, sets the
* <code>myInstance</code> property, resizes <code>myInstance</code> to
* the proper size and uses the ExternalInterface class to expose
* functions to Flash.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function LivePreviewParent()
{
// init Stage
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// grab pointer to our one and only child, the component
myInstance = getChildAt(0);
// resize our one and only child
onResize(stage.width, stage.height);
// register external interfaces
if (ExternalInterface.available) {
ExternalInterface.addCallback("onResize", onResize);
ExternalInterface.addCallback("onUpdate", onUpdate);
}
}
/**
* Resizes the component instance on the Stage to the specified
* dimensions, either by calling a user-defined method, or by
* separately setting the <code>width</code> and <code>height</code>
* properties.
*
* <p>This method is called by Flash Player.</p>
*
* @param width The new width for the <code>myInstance</code> instance.
* @param height The new height for the <code>myInstance</code> instance.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function onResize(width:Number, height:Number):void
{
var setSizeFn:Function = null;
try {
setSizeFn = myInstance["setSize"];
} catch (e:Error) {
setSizeFn = null;
}
if (setSizeFn != null) {
setSizeFn(width, height);
} else {
myInstance.width = width;
myInstance.height = height;
}
}
/**
* Updates the properties of the component instance.
* This method is called by Flash Player when there
* is a change in the value of a property. This method
* updates all component properties, whether or not
* they were changed.
*
* @param updateArray An array of parameter names and values.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function onUpdate(...updateArray:Array):void
{
propertyInspectorSettingUpdate(true);
for (var i:int = 0; i + 1 < updateArray.length; i += 2) {
try {
var name:String = String(updateArray[i]);
var value:* = updateArray[i+1];
if (typeof value == "object" && value.__treatAsCollectionSpecialSauce__) {
updateCollection(value, name);
} else {
myInstance[name] = value;
}
} catch (e:Error) {
}
}
propertyInspectorSettingUpdate(false);
}
public function propertyInspectorSettingUpdate(updating:Boolean):void
{
try {
myInstance["propertyInspectorSetting"] = updating;
} catch (e:Error) {
trace("propertyInspectorSettingUpdate error", e.message);
}
}
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private function updateCollection(collDesc:Object, index:String):void
{
// load classes, create object
var CollectionClass:Class = Class(getDefinitionByName(collDesc.collectionClass));
var CollectionItemClass:Class = Class(getDefinitionByName(collDesc.collectionItemClass));
var collObj:Object = new CollectionClass();
// iterate through array, populating collObj
for (var i:int = 0; i < collDesc.collectionArray.length; i++ ) {
var itemObj:Object = new CollectionItemClass();
var collProp:Object = collDesc.collectionArray[i];
for (var j:* in collProp) {
itemObj[j] = collProp[j];
}
collObj.addItem(itemObj);
}
// set the property
myInstance[index] = (collObj as CollectionClass);
}
}
}
| 108fantasy-tactics | trunk/fl/livepreview/LivePreviewParent.as | ActionScript | art | 7,612 |
//Target on map
package {
import flash.display.Sprite;
public class Target extends Sprite{
public function Target(ix:int, iy:int) {
x = ix;
y = iy;
graphics.lineStyle(1, 0xff0000);
graphics.moveTo( -10, -10);
graphics.lineTo(10, 10);
graphics.moveTo( -10, 10);
graphics.lineTo(10, -10);
}
}
}
| 108fantasy-tactics | trunk/Target.as | ActionScript | art | 370 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("hello")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KHTN")]
[assembly: AssemblyProduct("hello")]
[assembly: AssemblyCopyright("Copyright © KHTN 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1a0775c5-36af-4ee8-ba6a-3f64de3e1b73")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 0612153test | trunk/source/hello/hello/Properties/AssemblyInfo.cs | C# | asf20 | 1,430 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hello
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.WriteLine("Toi la PC1");
Console.WriteLine("PC3");
}
}
}
| 0612153test | trunk/source/hello/hello/Program.cs | C# | asf20 | 346 |
package org.esgl3d.spatial;
import java.util.ArrayList;
import org.esgl3d.rendering.RenderQueue;
import org.esgl3d.scene.CameraNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.scene.SceneNode;
public class NoneSpatialStructure implements SpatialStructure {
private final Scene attachedScene;
public NoneSpatialStructure(Scene scene) {
attachedScene = scene;
}
@Override
public void getVisibleNodes(CameraNode cam, RenderQueue queue) {
for (SceneNode curNode : attachedScene.getChildren())
renderNode(queue, curNode);
}
private void renderNode(RenderQueue queue, SceneNode node) {
queue.add(node);
if (node.hasChildren()) {
ArrayList<SceneNode> childs = node.getChildren();
for(SceneNode curNode : childs) {
renderNode(queue, curNode);
}
}
}
@Override
public void rebuild() {
// TODO Auto-generated method stub
}
@Override
public void update(SceneNode node) {
// TODO Auto-generated method stub
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/spatial/NoneSpatialStructure.java | Java | lgpl | 964 |
package org.esgl3d.spatial;
import org.esgl3d.rendering.RenderQueue;
import org.esgl3d.scene.CameraNode;
import org.esgl3d.scene.SceneNode;
/**
* Basic interface for any kind of spartial tree.
* @author michael
*
*/
public interface SpatialStructure {
/**
* Performs a full rebuild of the internal structure
*/
public void rebuild();
/**
* Updates information of a single scene node.
*
* @param node Node to update in the graph.
*/
public void update(SceneNode node);
/**
* Iterates the structure and adds visible nodes into the
* rendering queue.
*
* @param cam The currently active camera.
* @param queue The queue in which visible nodes are added.
*/
public void getVisibleNodes(CameraNode cam, RenderQueue queue);
}
| 12anyao-esgl | esgl/src/org/esgl3d/spatial/SpatialStructure.java | Java | lgpl | 763 |
package org.esgl3d.rendering;
import java.util.ArrayList;
import org.esgl3d.scene.SceneNode;
public class RenderQueue {
public enum RenderBucket {
Solid,
Transparent,
}
private ArrayList<SceneNode> nodesToRender = new ArrayList<SceneNode>();
public void reset() {
nodesToRender.clear();
}
public void add(SceneNode node) {
nodesToRender.add(node);
}
public ArrayList<SceneNode> getNodesToRender() {
return nodesToRender;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/RenderQueue.java | Java | lgpl | 459 |
package org.esgl3d.rendering;
/**
* @author michael
* This class represents options which specify how a vertex container is created.
*/
public class VertexContainerOptions {
private final boolean forceVertexArray;
public boolean isVertexArrayForced() {
return forceVertexArray;
}
public VertexContainerOptions(boolean setVertexArray) {
forceVertexArray = setVertexArray;
}
public static final VertexContainerOptions STATIC = new VertexContainerOptions(false);
public static final VertexContainerOptions DYNAMIC = new VertexContainerOptions(false);
public static final VertexContainerOptions FULL_DYNAMIC = new VertexContainerOptions(true);
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/VertexContainerOptions.java | Java | lgpl | 663 |
package org.esgl3d.rendering;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
class VertexBuffer extends VertexContainer {
private static Logger logger = Logger.getLogger(VertexBuffer.class.getName());
private final int vertexBufferId;
private final GL11 gl;
public VertexBuffer(int sizeInBytes, VertexFormat type, GL11 gl) {
super(sizeInBytes, type);
this.gl = gl;
int[] buffer = new int[1];
gl.glGenBuffers(1, buffer, 0);
vertexBufferId = buffer[0];
if (logger.isLoggable(Level.FINEST))
logger.finest(String.format("VBO-Id: %d", vertexBufferId));
}
void bind() {
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexBufferId);
}
void unbind() {
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
}
@Override
public void draw(PrimitiveType type, int startVerticeIndex, int numberOfVertices) {
int glType = GL11.GL_TRIANGLES;
switch (type) {
case Line:
glType = GL11.GL_LINES;
break;
case Point:
glType = GL11.GL_POINTS;
break;
case TriangleStrip:
glType = GL11.GL_TRIANGLE_STRIP;
break;
case Triangle:
break;
}
bind();
if (format.components[VertexFormat.COLOR] > 0) {
gl.glEnableClientState(GL11.GL_COLOR_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glColorPointer(format.components[VertexFormat.COLOR], GL11.GL_FLOAT, 0, format.offsets[VertexFormat.COLOR] * numberOfVertices*4);
else
gl.glColorPointer(format.components[VertexFormat.COLOR], GL11.GL_FLOAT, format.totalFloats*4, format.offsets[VertexFormat.COLOR]*4);
} else
gl.glDisableClientState(GL11.GL_COLOR_ARRAY);
if (format.components[VertexFormat.NORMAL] > 0) {
gl.glEnableClientState(GL11.GL_NORMAL_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glNormalPointer(GL11.GL_FLOAT, 0, format.offsets[VertexFormat.NORMAL] * numberOfVertices*4);
else
gl.glNormalPointer(GL11.GL_FLOAT, format.totalFloats*4, format.offsets[VertexFormat.NORMAL] *4);
} else
gl.glDisableClientState(GL11.GL_NORMAL_ARRAY);
if (format.components[VertexFormat.TEXTURE] > 0) {
gl.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glTexCoordPointer(format.components[VertexFormat.TEXTURE], GL11.GL_FLOAT, 0, format.offsets[VertexFormat.TEXTURE] * numberOfVertices*4);
else
gl.glTexCoordPointer(format.components[VertexFormat.TEXTURE], GL11.GL_FLOAT, format.totalFloats*4, format.offsets[VertexFormat.TEXTURE] *4);
} else
gl.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
if (format.components[VertexFormat.POSITION] > 0) {
gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glVertexPointer(format.components[VertexFormat.POSITION], GL11.GL_FLOAT, 0, format.offsets[VertexFormat.POSITION] * numberOfVertices*4);
else
gl.glVertexPointer(format.components[VertexFormat.POSITION], GL11.GL_FLOAT, format.totalFloats*4, format.offsets[VertexFormat.POSITION] *4);
} else
gl.glDisableClientState(GL11.GL_VERTEX_ARRAY);
gl.glDrawArrays(glType, startVerticeIndex, numberOfVertices);
unbind();
}
@Override
public void synchronize() {
bind();
buffer.position(0);
gl.glBufferData(GL11.GL_ARRAY_BUFFER, buffer.capacity()*4, buffer, GL11.GL_STATIC_DRAW);
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/VertexBuffer.java | Java | lgpl | 3,397 |
package org.esgl3d.rendering;
import java.nio.IntBuffer;
import javax.microedition.khronos.opengles.GL10;
import android.graphics.Bitmap;
import android.opengl.GLUtils;
public class TextureManager {
private GL10 gl;
public void setGl(GL10 value) {
gl = value;
}
public Texture addImage(Bitmap bitmap, boolean mipmaps) {
IntBuffer texturesBuffer = IntBuffer.allocate(1);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glGenTextures(1, texturesBuffer);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesBuffer.get(0));
int textuteMode = GL10.GL_LINEAR;
// setup texture parameters
if (mipmaps)
textuteMode = GL10.GL_LINEAR_MIPMAP_LINEAR;
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
textuteMode);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
textuteMode);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
GL10.GL_CLAMP_TO_EDGE);
if (mipmaps)
buildMipmap(gl, bitmap, 32);
else
buildMipmap(gl, bitmap, 1);
Texture result = new Texture(texturesBuffer.get(0), bitmap.getWidth(), bitmap.getHeight());
return result;
}
void buildMipmap(GL10 gl, Bitmap bitmap, int count) {
//
int level = 0;
//
int height = bitmap.getHeight();
int width = bitmap.getWidth();
while ( (height >= 1 || width >= 1) && (count > 0) ) {
// First of all, generate the texture from our bitmap and set it to
// the according level
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, level, bitmap, 0);
//
if (height == 1 || width == 1) {
break;
}
// Increase the mipmap level
level++;
//
height /= 2;
width /= 2;
Bitmap bitmap2 = Bitmap.createScaledBitmap(bitmap, width, height,
true);
// Clean up
bitmap.recycle();
bitmap = bitmap2;
count--;
}
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/TextureManager.java | Java | lgpl | 1,909 |
package org.esgl3d.rendering;
import java.nio.FloatBuffer;
import org.esgl3d.rendering.VertexContainer.BufferStructure;
/**
* Acts as a wrapper for legacy opengl commands. Handles internal state
* of color and texture coordinates.
*
* @author michael
*
*/
public class LegacyGLWrapper {
FloatBuffer buffer;
private float a;
private float r;
private float g;
private float b;
private float u;
private float v;
private VertexFormat type;
private int number;
private int numberOfVertices;
private VertexContainer container;
public LegacyGLWrapper(FloatBuffer setBuffer, VertexFormat format, VertexContainer setContainer) {
buffer = setBuffer;
type = format;
numberOfVertices = setContainer.getNumberOfVertices();
container = setContainer;
}
public void glBegin() {
number = 0;
}
public void glVertex2f(float x, float y) {
glVertex3f(x, y, 0);
}
public void glVertex3f(float x, float y, float z) {
if (container.structure == BufferStructure.Stacked) {
// write color parts
if (type.components[VertexFormat.COLOR] > 0) {
buffer.position(type.offsets[VertexFormat.COLOR]*numberOfVertices + number*type.components[VertexFormat.COLOR]);
buffer.put(r);
buffer.put(g);
buffer.put(b);
buffer.put(a);
}
// write texture parts
if (type.components[VertexFormat.TEXTURE] > 0) {
buffer.position(type.offsets[VertexFormat.TEXTURE]*numberOfVertices + number*type.components[VertexFormat.TEXTURE]);
buffer.put(u);
buffer.put(v);
}
// write vertex parts
if (type.components[VertexFormat.POSITION] == 2) {
buffer.position(type.offsets[VertexFormat.POSITION]*numberOfVertices + number*type.components[VertexFormat.POSITION]);
buffer.put(x);
buffer.put(y);
} else if (type.components[VertexFormat.POSITION] == 3) {
buffer.position(type.offsets[VertexFormat.POSITION]*numberOfVertices + number*type.components[VertexFormat.POSITION]);
buffer.put(x);
buffer.put(y);
buffer.put(z);
}
} else {
buffer.position(type.totalFloats * number);
// write color parts
if (type.components[VertexFormat.COLOR] > 0) {
buffer.put(r);
buffer.put(g);
buffer.put(b);
buffer.put(a);
}
// write texture parts
if (type.components[VertexFormat.TEXTURE] > 0) {
buffer.put(u);
buffer.put(v);
}
// write vertex parts
if (type.components[VertexFormat.POSITION] == 2) {
buffer.put(x);
buffer.put(y);
} else if (type.components[VertexFormat.POSITION] == 3) {
buffer.put(x);
buffer.put(y);
buffer.put(z);
}
}
number ++;
}
public void glTexCoord2f(float u, float v) {
this.u = u;
this.v = v;
}
public void glColor4f(float r, float g, float b,float a) {
this.a = a;
this.r = r;
this.g = g;
this.b = b;
}
public void glEnd() {
// does nothing
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/LegacyGLWrapper.java | Java | lgpl | 2,873 |
package org.esgl3d.rendering;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import android.R.integer;
public abstract class VertexContainer {
public enum PrimitiveType {
Triangle,
TriangleStrip,
Line,
Quad,
Point
}
/**
* Type of Buffer
* @author michael
*/
public enum BufferStructure {
Stacked,
Interleaved,
}
protected final FloatBuffer buffer;
protected final int numberOfVertices;
protected final VertexFormat format;
protected final BufferStructure structure;
VertexContainer(int setNumberOfVertices, VertexFormat ftype) {
buffer = ByteBuffer.allocateDirect(setNumberOfVertices * (ftype.totalFloats*4))
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
numberOfVertices = setNumberOfVertices;
format = ftype;
structure = BufferStructure.Interleaved;
}
public abstract void draw(PrimitiveType type, int startingVertice, int numberOfVertices);
/**
* Synchronizes the buffer with the one in video memory.
*/
public abstract void synchronize();
private void putValues(int index, int type, float... data) {
if (format.components[type]== 0)
return;
if (structure == BufferStructure.Stacked)
buffer.position(format.offsets[type] * numberOfVertices + format.components[type] * index);
else
buffer.position(format.totalFloats * index + format.offsets[type]);
buffer.put(data[0]);
buffer.put(data[1]);
if (format.components[type]==3)
buffer.put(data[2]);
if (format.components[type]==4)
buffer.put(data[3]);
}
/**
* Sets positional data at the specified index
* @param index
* @param data
*/
public void setPosition(int index, float... data) {
putValues(index, VertexFormat.POSITION, data);
}
/**
* Sets texture u/v coordinates at the specified index
* @param index
* @param data
*/
public void setTexture(int index, float... data) {
putValues(index, VertexFormat.TEXTURE, data);
}
/**
* Sets color information at the specified index
* @param index
* @param data
*/
public void setColor(int index, float... data) {
putValues(index, VertexFormat.COLOR, data);
}
/**
* Returns a new legacy wrapper.
* @return a new wrapper object which wraps this container
*/
public LegacyGLWrapper getLegacyGLInterface() {
return new LegacyGLWrapper(buffer,format, this);
}
/**
* @return number of vertices in this container
*/
public int getNumberOfVertices() {
return numberOfVertices;
}
/**
* releases the buffer
*/
public void release() {
// TODO Auto-generated method stub
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/VertexContainer.java | Java | lgpl | 2,687 |
package org.esgl3d.rendering;
import android.R.integer;
public class VertexFormat {
static final int COLOR = 0;
static final int NORMAL = 1;
static final int TEXTURE = 2;
static final int POSITION = 3;
final int[] components = new int[4];
final int[] offsets = new int[4];
final int totalFloats;
final boolean isInterleaved;
private VertexFormat(int setColorComp, int setTextureComp, int setPositionComp, boolean setInterleaved) {
components[COLOR] = setColorComp;
components[NORMAL] = 0;
components[TEXTURE] = setTextureComp;
components[POSITION] = setPositionComp;
int total = 0;
for (int i=0;i<4;i++) {
offsets[i] = 0;
for (int x=0;x<i;x++)
offsets[i] += components[x];
total += components[i];
}
totalFloats = total;
isInterleaved = setInterleaved;
}
// color, normal, textureX, position
public static final VertexFormat F_4Color_3Position = new VertexFormat(4, 0, 3,false);
public static final VertexFormat F_2Texture_3Position = new VertexFormat(0, 2, 3, false);
public static final VertexFormat F_2Texture_2Position = new VertexFormat(0, 2, 2, false);
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/VertexFormat.java | Java | lgpl | 1,121 |
package org.esgl3d.rendering;
import javax.microedition.khronos.opengles.GL10;
import android.graphics.Bitmap;
import android.opengl.GLUtils;
public class Texture {
private final int textureId;
private final int width;
private final int height;
public int getHeight() {
return height;
}
public int getWidth() {
return width;
}
public int getTextureId() {
return textureId;
}
public void bind(GL10 gl) {
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
}
Texture(int id, int setWidth, int setHeight) {
textureId = id;
width = setWidth;
height = setHeight;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/Texture.java | Java | lgpl | 603 |
package org.esgl3d.rendering;
import java.lang.ref.Reference;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import org.esgl3d.Mesh;
import org.esgl3d.Mesh.Format;
import org.esgl3d.math.Matrix;
import org.esgl3d.primitives.Pyramid;
import org.esgl3d.rendering.VertexContainer.PrimitiveType;
import org.esgl3d.scene.MeshNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.scene.SceneNode;
import org.esgl3d.util.FpsCounter;
import org.esgl3d.util.HighPerformanceCounter;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
public class Renderer implements GLSurfaceView.Renderer {
private static Logger logger = Logger.getLogger(Renderer.class.getName());
public enum MatrixType {
Projection,
ModelView
}
private RenderCaps caps;
private GL10 gl;
private SceneNode p;
private RenderQueue queue = new RenderQueue();
private HighPerformanceCounter timeForRendering = new HighPerformanceCounter("Rendering");
private TextureManager textureManager = null;
private Scene sceneToRender = null;
private final RenderActivity renderActivity;
private final FpsCounter fpsCounter;
public Renderer(RenderActivity renderActivity) {
this.renderActivity = renderActivity;
textureManager = new TextureManager();
fpsCounter = new FpsCounter();
}
public void setScene(Scene value) {
sceneToRender = value;
}
public TextureManager getTextureManager() {
return textureManager;
}
public FpsCounter getFpsCounter() {
return fpsCounter;
}
@Override
public void onDrawFrame(GL10 arg0) {
fpsCounter.next();
setPerspectiveProjection();
gl.glClearColor(0, 0, 0, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0.0f,0.0f,-32.0f);
render(this);
renderActivity.updateScenegraph();
}
@Override
public void onSurfaceChanged(GL10 arg0, int width, int height) {
gl.glViewport(0, 0, width, height); // Reset The Current Viewport And Perspective Transformation
gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix
gl.glLoadIdentity(); // Reset The Projection Matrix
GLU.gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 100.0f); // Calculate The Aspect Ratio Of The Window
gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix
gl.glLoadIdentity(); // Reset The ModalView Matrix
}
@Override
public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
gl = arg0;
caps = new RenderCaps();
caps.initialize(gl);
textureManager.setGl(gl);
//gl.glShadeModel(GL10.GL_SMOOTH); //Enables Smooth Color Shading
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //This Will Clear The Background Color To Black
gl.glClearDepthf((float) 1.0); //Enables Clearing Of The Depth Buffer
gl.glEnable(GL10.GL_DEPTH_TEST); //Enables Depth Testing
gl.glDepthFunc(GL10.GL_LEQUAL); //The Type Of Depth Test To Do
//gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); // Really Nice Perspective Calculations
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnable(GL10.GL_CULL_FACE);
// which is the front? the one which is drawn counter clockwise
gl.glFrontFace(GL10.GL_CCW);
// which one should NOT be drawn
/*gl.glEnable(GL10.GL_COLOR_MATERIAL);
gl.glCullFace(GL10.GL_BACK);
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);*/
renderActivity.setupScenegraph();
}
/**
* Creates a vertex container to be used by the application. The renderer
* decides whether it is implemented as a vertex array or vbo.
*
* @param format Vertex format
* @param numberOfVertices The total number of vertices
* @return a newly created vertex container
*/
public VertexContainer createVertexContainer(VertexFormat format, int numberOfVertices) {
return createVertexContainer(format, numberOfVertices, VertexContainerOptions.DYNAMIC);
}
/**
* Creates a vertex container to be used by the application. The renderer
* decides whether it is implemented as a vertex array or vbo.
*
* @param format Vertex format
* @param numberOfVertices The total number of vertices
* @param options Options to further specify the usage
* @return a newly created vertex container
*/
public VertexContainer createVertexContainer(VertexFormat format, int numberOfVertices, VertexContainerOptions options) {
if (!caps.isVboSupported() || options.isVertexArrayForced()) {
if (logger.isLoggable(Level.FINE))
logger.fine( String.format("Using Vertex Array (%d vertices)", numberOfVertices));
return new VertexArray(numberOfVertices, format, gl);
}
else {
if (logger.isLoggable(Level.FINE))
logger.fine( String.format("Using Vertex Buffer Object (%d vertices)", numberOfVertices));
//return new VertexArray(numberOfVertices, format, gl);
return new VertexBuffer(numberOfVertices, format, (GL11)gl);
}
}
public void activeMatrixModel(MatrixType type) {
if (type == MatrixType.ModelView)
gl.glMatrixMode(GL10.GL_MODELVIEW);
else
gl.glMatrixMode(GL10.GL_PROJECTION);
}
public void loadMatrix(Matrix m) {
gl.glLoadMatrixf(m.buffer);
}
public void pushMatrix() {
gl.glPushMatrix();
}
public void popMatrix() {
gl.glPopMatrix();
}
public void mulMatrix(Matrix m) {
gl.glMultMatrixf(m.buffer);
}
public void setPerspectiveProjection() {
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluPerspective(gl, 45, 320.0f/480.0f, 0.1f, 1000);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
public void setOrthographicProjection() {
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0, 20, 30, 0);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
private int currentlyBoundTexture = 0;
private boolean texturingEnabled = false;
/**
* Sets the appropriate opengl states for textures
*
* @param toBind texture to bind or null to unbind
*/
public void bindTexture(Texture toBind) {
if (toBind != null) {
if (!texturingEnabled) {
gl.glEnable(GL10.GL_TEXTURE_2D);
texturingEnabled = true;
}
if (currentlyBoundTexture != toBind.getTextureId()) {
gl.glBindTexture(GL10.GL_TEXTURE_2D, toBind.getTextureId());
currentlyBoundTexture = toBind.getTextureId();
}
} else {
if (texturingEnabled) {
gl.glDisable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
currentlyBoundTexture = 0;
texturingEnabled = false;
}
}
}
public GL10 getGl() {
return gl;
}
public void render(Renderer renderer) {
timeForRendering.start();
queue.reset();
if (sceneToRender != null)
sceneToRender.getSpatialStructure().getVisibleNodes(null, queue);
renderer.activeMatrixModel(MatrixType.ModelView);
for (SceneNode curNode : queue.getNodesToRender()) {
if (curNode instanceof MeshNode) {
MeshNode cur = (MeshNode)curNode;
Mesh geometry = cur.getGeometry();
int count = cur.getGeometry().getNumberOfVertices();
bindTexture(geometry.getTexture());
renderer.pushMatrix();
renderer.mulMatrix(cur.getWorldTransformation());
Format format = geometry.getFormat();
if (format == Format.Triangle) {
geometry.getVertices().draw(PrimitiveType.Triangle, 0, count);
} else {
geometry.getVertices().draw(PrimitiveType.TriangleStrip, 0, count);
}
renderer.popMatrix();
}
}
timeForRendering.stop();
if (timeForRendering.getCounterDurationMillis() > 5000) {
if (logger.isLoggable(Level.INFO))
logger.info(timeForRendering.getStatisticString());
timeForRendering.reset();
}
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/Renderer.java | Java | lgpl | 8,271 |
package org.esgl3d.rendering;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.khronos.opengles.GL10;
/**
* @author michael
*
*/
public class RenderCaps {
private static Logger log = Logger.getLogger(RenderCaps.class.getName());
private boolean isSoftwareRenderer = false;
private boolean isVboSupported = false;
private boolean isOpenGL10 = false;
public boolean isSoftwareRenderer() {
return isSoftwareRenderer;
}
public boolean isVboSupported() {
return isVboSupported;
}
/**
* Checks if opengl-es 1.0 is available.
* @return true if available
*/
public boolean isOpenGL10() {
return isOpenGL10;
}
/**
* Checks if opengl-es 1.1 is available
* @return true if available
*/
public boolean isOpenGL11() {
return !isOpenGL10;
}
/**
* Checks if opengl-es 2.0 is available
* @return always false since opengl-es 2.0 is not supported
*/
public boolean isOpenGL20() {
return false;
}
public void initialize(GL10 gl) {
String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
String renderer = gl.glGetString(GL10.GL_RENDERER);
String version = gl.glGetString(GL10.GL_VERSION);
if (log.isLoggable(Level.INFO)) {
log.info(extensions);
log.info(renderer);
log.info(version);
}
isSoftwareRenderer = renderer.contains("PixelFlinger");
isOpenGL10 = version.contains("1.0");
isVboSupported = !isSoftwareRenderer && (!isOpenGL10 || extensions.contains("vertex_buffer_object"));
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/RenderCaps.java | Java | lgpl | 1,511 |
package org.esgl3d.rendering;
public class Layer {
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/Layer.java | Java | lgpl | 55 |
package org.esgl3d.rendering;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
class VertexArray extends VertexContainer {
private final GL10 gl;
public VertexArray(int sizeInBytes, VertexFormat type, GL10 gl) {
super(sizeInBytes,type);
this.gl = gl;
}
@Override
public void draw(PrimitiveType type, int startVerticeIndex, int numberOfVertices) {
int glType = GL10.GL_TRIANGLES;
switch (type) {
case Line:
glType = GL10.GL_LINES;
break;
case Point:
glType = GL10.GL_POINTS;
break;
case TriangleStrip:
glType = GL10.GL_TRIANGLE_STRIP;
break;
case Triangle:
break;
}
if (format.components[VertexFormat.COLOR] > 0) {
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glColorPointer(format.components[VertexFormat.COLOR], GL10.GL_FLOAT, 0, buffer.position(format.offsets[VertexFormat.COLOR] * numberOfVertices));
else
gl.glColorPointer(format.components[VertexFormat.COLOR], GL10.GL_FLOAT, format.totalFloats, buffer.position(format.offsets[VertexFormat.COLOR]));
} else
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
if (format.components[VertexFormat.NORMAL] > 0) {
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glNormalPointer(GL10.GL_FLOAT, 0, buffer.position(format.offsets[VertexFormat.NORMAL] * numberOfVertices));
else
gl.glNormalPointer(GL10.GL_FLOAT, format.totalFloats, buffer.position(format.offsets[VertexFormat.NORMAL]));
} else
gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
if (format.components[VertexFormat.TEXTURE] > 0) {
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glTexCoordPointer(format.components[VertexFormat.TEXTURE], GL10.GL_FLOAT, 0, buffer.position(format.offsets[VertexFormat.TEXTURE] * numberOfVertices));
else
gl.glTexCoordPointer(format.components[VertexFormat.TEXTURE], GL10.GL_FLOAT, format.totalFloats, buffer.position(format.offsets[VertexFormat.TEXTURE]));
} else
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
if (format.components[VertexFormat.POSITION] > 0) {
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
if (structure == BufferStructure.Stacked)
gl.glVertexPointer(format.components[VertexFormat.POSITION], GL10.GL_FLOAT, 0, buffer.position(format.offsets[VertexFormat.POSITION] * numberOfVertices));
else
gl.glVertexPointer(format.components[VertexFormat.POSITION], GL10.GL_FLOAT, format.totalFloats, buffer.position(format.offsets[VertexFormat.POSITION]));
} else
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDrawArrays(glType, startVerticeIndex, numberOfVertices);
}
@Override
public void synchronize() {
// TODO Auto-generated method stub
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/rendering/VertexArray.java | Java | lgpl | 2,874 |
package org.esgl3d.util;
public class HighPerformanceCounter {
private long firstStart = 0;
private long start = 0;
private long lastElapsed = 0;
private boolean isRunning = false;
private long totalElapsed = 0;
private long totalStops = 0;
private final String name;
public HighPerformanceCounter(String nameString) {
name = nameString;
}
public void start() {
start = System.nanoTime();
if (firstStart == 0)
firstStart = start;
isRunning = true;
}
public void stop() {
lastElapsed = System.nanoTime() - start;
isRunning = false;
totalStops += 1;
totalElapsed += lastElapsed;
}
public void reset() {
totalElapsed = 0;
totalStops = 0;
lastElapsed = 0;
firstStart = 0;
start = 0;
isRunning = false;
}
public long getTotalStops() {
return totalStops;
}
public long getCounterDurationMillis() {
if (firstStart > 0) {
long duration = (System.nanoTime() - firstStart) / (1000*1000);
return duration;
}
return 0;
}
public long getAverageTotalElapsedMillis() {
if (totalStops > 0) {
return (totalElapsed / totalStops) / (1000*1000);
}
return 0;
}
public String getStatisticString() {
return
String.format("%s: Cnt: %d Avg: %dms", name, getTotalStops(), getAverageTotalElapsedMillis());
}
public long getElapsedMillis() {
long total = lastElapsed;
if (isRunning)
total += (System.nanoTime() - start);
long diffInMillis = total / (1000*1000);
return diffInMillis;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/util/HighPerformanceCounter.java | Java | lgpl | 1,487 |
package org.esgl3d.util;
public class FpsCounter {
private int lastFps = 0;
private int currentFps;
private int lastDelta = 0;
private long lastMillis = System.currentTimeMillis();
private long lastNextMillis = System.currentTimeMillis();
private String lastFpsString = "";
public int getLastFps() {
return lastFps;
}
public int getLastDelta() {
return lastDelta;
}
public void next() {
currentFps++;
if (System.currentTimeMillis() > lastMillis+1000) {
if (lastFps != currentFps)
lastFpsString = String.format("FPS: %d", currentFps);
lastFps = currentFps;
currentFps = 0;
lastMillis = System.currentTimeMillis();
}
lastDelta = (int)(System.currentTimeMillis() - lastNextMillis);
lastNextMillis = System.currentTimeMillis();
}
@Override
public String toString() {
return lastFpsString;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/util/FpsCounter.java | Java | lgpl | 861 |
package org.esgl3d.scene;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LightNode extends SceneNode {
private static final Logger logger = Logger.getLogger(LightNode.class.getName());
@Override
protected void onSceneSwitch(Scene from, Scene to) {
if (from != null) {
if (logger.isLoggable(Level.FINE))
logger.fine("Removing light from scene");
from.unregisterLightNode(this);
}
if (to != null) {
if (logger.isLoggable(Level.FINE))
logger.fine("Adding light to scene");
to.registerLightNode(this);
}
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/scene/LightNode.java | Java | lgpl | 576 |
package org.esgl3d.scene;
import java.util.ArrayList;
import org.esgl3d.Mesh;
import org.esgl3d.math.Matrix;
import org.esgl3d.primitives.Pyramid;
import org.esgl3d.rendering.Renderer;
import com.sun.org.apache.xpath.internal.axes.ChildIterator;
/**
* SceneNode represents a single node of a scene graph. SceneNode can have
* any number of children attached to it.
*
* @author michael
*/
public class SceneNode {
private Matrix localTransformation = new Matrix();
private Matrix worldTransformation = new Matrix();
private boolean isDirty = false;
private SceneNode parentNode;
private Scene owner;
private ArrayList<SceneNode> childNodes = new ArrayList<SceneNode>();
void setScene(Scene newScene) {
if (owner != newScene)
onSceneSwitch(owner, newScene);
owner = newScene;
}
/**
* Called when a scene node switches from one scene to another
* @param from Old scene
* @param to New scene
*/
protected void onSceneSwitch(Scene from, Scene to) {
}
public Scene getScene() {
return owner;
}
/**
* @return true if this scene node (or any of its parent) has been moved
*/
public boolean isDirty() {
return isDirty;
}
/**
* resets the dirty flag to 'false'
*/
public void unsetDirtyFlag() {
isDirty = false;
}
/**
* Return the local transformation relative to the parent
*
* @return Matrix (local tranformation)
*/
public Matrix getLocalTransformation() {
return localTransformation;
}
/**
* Calculates and returns the world transformation
*
* @return Matrix (world transformation)
*/
public Matrix getWorldTransformation() {
// quick and dirty...
Matrix.assign(worldTransformation.v, localTransformation.v);
SceneNode next = parentNode;
while (next != null) {
Matrix.preMultiplyMM(worldTransformation.v, next.localTransformation.v);
next = next.parentNode;
}
return worldTransformation;
}
/**
* Translates (moves) this scene node
*
* @param x
* @param y
* @param z
*/
public void translate(float x, float y, float z) {
Matrix.translateM(localTransformation.v, 0, x, y, z);
isDirty = true;
}
/**
* Rotates this scene node around its center
*
* @param deg
* @param x
* @param y
* @param z
*/
public void rotate(float deg, float x, float y, float z) {
Matrix.rotateM(localTransformation.v, 0, deg, x, y, z);
}
/**
* Checks if this node has any children
*
* @return true if there are children, otherwise false
*/
public boolean hasChildren() {
return childNodes.size()>0;
}
public ArrayList<SceneNode> getChildren() {
return childNodes;
}
public boolean checkCulling() {
// currently always visible
return true;
}
private void setParentNode(SceneNode newParent) {
parentNode = newParent;
Scene newScene = null;
if (newParent != null)
newScene = newParent.owner;
if (newScene != owner)
setOwningSceneRecursively(newScene);
}
void setOwningSceneRecursively(Scene set) {
setScene(set);
for (SceneNode curNode : childNodes) {
curNode.setOwningSceneRecursively(set);
}
}
/**
* Detaches this node from its parent.
*/
public void detach() {
if (parentNode != null) {
parentNode.detachChild(this);
} else {
owner.removeChild(this);
}
}
/**
* Attaches this node to a new parent.
* @param newParent
*/
public void attachTo(SceneNode newParent) {
newParent.attachChild(this);
}
/**
* Attaches a node as child. Detaches it if it has already a parent.
* @param node
*/
public void attachChild(SceneNode node) {
if (node.parentNode != null)
node.parentNode.detachChild(node);
node.setParentNode(this);
childNodes.add(node);
}
/**
* Detaches a specific child.
* @param child
*/
public void detachChild(SceneNode child) {
if (childNodes.contains(child))
{
child.parentNode = null;
childNodes.remove(child);
}
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/scene/SceneNode.java | Java | lgpl | 3,918 |
package org.esgl3d.scene;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.esgl3d.rendering.RenderQueue;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.Renderer.MatrixType;
import org.esgl3d.rendering.VertexContainer.PrimitiveType;
import org.esgl3d.spatial.NoneSpatialStructure;
import org.esgl3d.spatial.SpatialStructure;
import org.esgl3d.util.HighPerformanceCounter;
public class Scene {
private static final Logger logger = Logger.getLogger(Scene.class.getName());
private ArrayList<SceneNode> childNodes = new ArrayList<SceneNode>();
private ArrayList<LightNode> lightNodes = new ArrayList<LightNode>();
private SpatialStructure spatialSeperator = null;
public SpatialStructure getSpatialStructure() {
return spatialSeperator;
}
public Scene() {
spatialSeperator = new NoneSpatialStructure(this);
}
public void addChild(SceneNode node) {
childNodes.add(node);
node.setOwningSceneRecursively(this);
}
public void removeChild(SceneNode node) {
childNodes.remove(node);
node.setOwningSceneRecursively(null);
}
public ArrayList<SceneNode> getChildren() {
return childNodes;
}
public void registerLightNode(LightNode node) {
if (!lightNodes.contains(node))
lightNodes.add(node);
}
public void unregisterLightNode(LightNode node) {
if (lightNodes.contains(node))
lightNodes.remove(node);
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/scene/Scene.java | Java | lgpl | 1,432 |
package org.esgl3d.scene;
import org.esgl3d.Mesh;
import org.esgl3d.rendering.Texture;
public class MeshNode extends SceneNode {
private Mesh geometry;
public Mesh getGeometry() {
return geometry;
}
public void setGeometry(Mesh value) {
geometry = value;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/scene/MeshNode.java | Java | lgpl | 275 |
package org.esgl3d.scene;
public class CameraNode extends SceneNode {
}
| 12anyao-esgl | esgl/src/org/esgl3d/scene/CameraNode.java | Java | lgpl | 74 |
package org.esgl3d.math;
public class Vector3d {
private static final Vector3d ORIGIN = new Vector3d(0f, 0f, 0f);
public float x;
public float y;
public float z;
public Vector3d(final Vector3d other) {
x = other.x;
y = other.y;
z = other.z;
}
public Vector3d(float xComp, float yComp, float zComp) {
x = xComp;
y = yComp;
z = zComp;
}
public Vector3d plus(float xComp, float yComp, float zComp) {
return new Vector3d(x + xComp, y + yComp, z + zComp);
}
public Vector3d minus(float xComp, float yComp, float zComp) {
return new Vector3d(x - xComp, y - yComp, z - zComp);
}
public String toString() {
return "["+x+","+y+","+z+"]";
}
public Vector3d times(float comp) {
return times(comp, comp, comp);
}
public Vector3d times(float xComp, float yComp, float zComp) {
return new Vector3d(x * xComp, y * yComp, z * zComp);
}
public Vector3d scale(float scaleValue) {
return new Vector3d(x * scaleValue, y * scaleValue, z * scaleValue);
}
public Vector3d divide(float comp) {
return new Vector3d(x / comp, y / comp, z / comp);
}
public float length() {
return (float) Math.sqrt((x*x)+(y*y)+(z*z));
}
public Vector3d normalize() {
float len = length();
return new Vector3d(x / len, y / len, z / len);
}
public Vector3d times(Vector3d other) {
return this.times(other.x, other.y, other.z);
}
public Vector3d plus(Vector3d other) {
return this.plus(other.x, other.y, other.z);
}
public Vector3d minus(Vector3d other) {
return this.minus(other.x, other.y, other.z);
}
public Vector3d cross(Vector3d other) {
float newX = y * other.z - other.y * z;
float newY = z * other.x - other.z * x;
float newZ = x * other.y - other.x * y;
return new Vector3d(newX, newY, newZ);
}
public float dot(Vector3d other) {
return x * other.x + y * other.y + z * other.z;
}
public Vector3d negative() {
return new Vector3d(-x, -y, -z);
}
public void normalizeMutable() {
float len = length();
x = x / len;
y = y / len;
z = z / len;
}
} | 12anyao-esgl | esgl/src/org/esgl3d/math/Vector3d.java | Java | lgpl | 2,324 |
package org.esgl3d.math;
import java.nio.FloatBuffer;
import android.R.integer;
/**
* This class is straight from android sources with some modifications
*/
/**
* Matrix math utilities. These methods operate on OpenGL ES format
* matrices and vectors stored in float arrays.
*
* Matrices are 4 x 4 column-vector matrices stored in column-major
* order:
* <pre>
* m[offset + 0] m[offset + 4] m[offset + 8] m[offset + 12]
* m[offset + 1] m[offset + 5] m[offset + 9] m[offset + 13]
* m[offset + 2] m[offset + 6] m[offset + 10] m[offset + 14]
* m[offset + 3] m[offset + 7] m[offset + 11] m[offset + 15]
* </pre>
*
* Vectors are 4 row x 1 column column-vectors stored in order:
* <pre>
* v[offset + 0]
* v[offset + 1]
* v[offset + 2]
* v[offset + 3]
* </pre>
*
*/
public class Matrix {
public volatile float[] v =null;
public volatile FloatBuffer buffer = null;
/**
* Multiply two 4x4 matrices together and store the result in a third 4x4
* matrix. In matrix notation: result = lhs x rhs. Due to the way
* matrix multiplication works, the result matrix will have the same
* effect as first multiplying by the rhs matrix, then multiplying by
* the lhs matrix. This is the opposite of what you might expect.
*
* The same float array may be passed for result, lhs, and/or rhs. However,
* the result element values are undefined if the result elements overlap
* either the lhs or rhs elements.
*
* @param result The float array that holds the result.
* @param resultOffset The offset into the result array where the result is
* stored.
* @param lhs The float array that holds the left-hand-side matrix.
* @param lhsOffset The offset into the lhs array where the lhs is stored
* @param rhs The float array that holds the right-hand-side matrix.
* @param rhsOffset The offset into the rhs array where the rhs is stored.
*
* @throws IllegalArgumentException if result, lhs, or rhs are null, or if
* resultOffset + 16 > result.length or lhsOffset + 16 > lhs.length or
* rhsOffset + 16 > rhs.length.
*/
public Matrix() {
v = new float[16];
buffer = FloatBuffer.wrap(v);
Matrix.setIdentityM(v, 0);
}
public static void multiplyMM(float[] result, int resultOffset,
float[] lhs, int lhsOffset, float[] rhs, int rhsOffset) {
int i, j, k;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
int tmpIdx = 4*j+i;
result[tmpIdx+resultOffset] = 0.0f;
for (k = 0; k < 4; k++) {
result[tmpIdx+resultOffset] += lhs[4*k+i+lhsOffset] * rhs[4*j+k+rhsOffset];
}
}
// assign(dst, tmp);
}
public static void multiplyMM(float[] lhs, int lhsOffset, float[] rhs, int rhsOffset) {
float[] result = new float[16];
int i, j, k;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
int tmpIdx = 4*j+i;
result[tmpIdx] = 0.0f;
for (k = 0; k < 4; k++) {
result[tmpIdx] += lhs[4*k+i+lhsOffset] * rhs[4*j+k+rhsOffset];
}
}
lhs = result;
}
/**
* Multiply a 4 element vector by a 4x4 matrix and store the result in a 4
* element column vector. In matrix notation: result = lhs x rhs
*
* The same float array may be passed for resultVec, lhsMat, and/or rhsVec.
* However, the resultVec element values are undefined if the resultVec
* elements overlap either the lhsMat or rhsVec elements.
*
* @param resultVec The float array that holds the result vector.
* @param resultVecOffset The offset into the result array where the result
* vector is stored.
* @param lhsMat The float array that holds the left-hand-side matrix.
* @param lhsMatOffset The offset into the lhs array where the lhs is stored
* @param rhsVec The float array that holds the right-hand-side vector.
* @param rhsVecOffset The offset into the rhs vector where the rhs vector
* is stored.
*
* @throws IllegalArgumentException if resultVec, lhsMat,
* or rhsVec are null, or if resultVecOffset + 4 > resultVec.length
* or lhsMatOffset + 16 > lhsMat.length or
* rhsVecOffset + 4 > rhsVec.length.
*/
public static void multiplyMV(float[] resultVec,
int resultVecOffset, float[] lhsMat, int lhsMatOffset,
float[] rhsVec, int rhsVecOffset) {
throw new RuntimeException("Not implemented.");
}
/**
* Transposes a 4 x 4 matrix.
*
* @param mTrans the array that holds the output inverted matrix
* @param mTransOffset an offset into mInv where the inverted matrix is
* stored.
* @param m the input array
* @param mOffset an offset into m where the matrix is stored.
*/
public static void transposeM(float[] mTrans, int mTransOffset, float[] m,
int mOffset) {
for (int i = 0; i < 4; i++) {
int mBase = i * 4 + mOffset;
mTrans[i + mTransOffset] = m[mBase];
mTrans[i + 4 + mTransOffset] = m[mBase + 1];
mTrans[i + 8 + mTransOffset] = m[mBase + 2];
mTrans[i + 12 + mTransOffset] = m[mBase + 3];
}
}
/**
* Inverts a 4 x 4 matrix.
*
* @param mInv the array that holds the output inverted matrix
* @param mInvOffset an offset into mInv where the inverted matrix is
* stored.
* @param m the input array
* @param mOffset an offset into m where the matrix is stored.
* @return true if the matrix could be inverted, false if it could not.
*/
public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
int mOffset) {
// Invert a 4 x 4 matrix using Cramer's Rule
// array of transpose source matrix
float[] src = new float[16];
// transpose matrix
transposeM(src, 0, m, mOffset);
// temp array for pairs
float[] tmp = new float[12];
// calculate pairs for first 8 elements (cofactors)
tmp[0] = src[10] * src[15];
tmp[1] = src[11] * src[14];
tmp[2] = src[9] * src[15];
tmp[3] = src[11] * src[13];
tmp[4] = src[9] * src[14];
tmp[5] = src[10] * src[13];
tmp[6] = src[8] * src[15];
tmp[7] = src[11] * src[12];
tmp[8] = src[8] * src[14];
tmp[9] = src[10] * src[12];
tmp[10] = src[8] * src[13];
tmp[11] = src[9] * src[12];
// Holds the destination matrix while we're building it up.
float[] dst = new float[16];
// calculate first 8 elements (cofactors)
dst[0] = tmp[0] * src[5] + tmp[3] * src[6] + tmp[4] * src[7];
dst[0] -= tmp[1] * src[5] + tmp[2] * src[6] + tmp[5] * src[7];
dst[1] = tmp[1] * src[4] + tmp[6] * src[6] + tmp[9] * src[7];
dst[1] -= tmp[0] * src[4] + tmp[7] * src[6] + tmp[8] * src[7];
dst[2] = tmp[2] * src[4] + tmp[7] * src[5] + tmp[10] * src[7];
dst[2] -= tmp[3] * src[4] + tmp[6] * src[5] + tmp[11] * src[7];
dst[3] = tmp[5] * src[4] + tmp[8] * src[5] + tmp[11] * src[6];
dst[3] -= tmp[4] * src[4] + tmp[9] * src[5] + tmp[10] * src[6];
dst[4] = tmp[1] * src[1] + tmp[2] * src[2] + tmp[5] * src[3];
dst[4] -= tmp[0] * src[1] + tmp[3] * src[2] + tmp[4] * src[3];
dst[5] = tmp[0] * src[0] + tmp[7] * src[2] + tmp[8] * src[3];
dst[5] -= tmp[1] * src[0] + tmp[6] * src[2] + tmp[9] * src[3];
dst[6] = tmp[3] * src[0] + tmp[6] * src[1] + tmp[11] * src[3];
dst[6] -= tmp[2] * src[0] + tmp[7] * src[1] + tmp[10] * src[3];
dst[7] = tmp[4] * src[0] + tmp[9] * src[1] + tmp[10] * src[2];
dst[7] -= tmp[5] * src[0] + tmp[8] * src[1] + tmp[11] * src[2];
// calculate pairs for second 8 elements (cofactors)
tmp[0] = src[2] * src[7];
tmp[1] = src[3] * src[6];
tmp[2] = src[1] * src[7];
tmp[3] = src[3] * src[5];
tmp[4] = src[1] * src[6];
tmp[5] = src[2] * src[5];
tmp[6] = src[0] * src[7];
tmp[7] = src[3] * src[4];
tmp[8] = src[0] * src[6];
tmp[9] = src[2] * src[4];
tmp[10] = src[0] * src[5];
tmp[11] = src[1] * src[4];
// calculate second 8 elements (cofactors)
dst[8] = tmp[0] * src[13] + tmp[3] * src[14] + tmp[4] * src[15];
dst[8] -= tmp[1] * src[13] + tmp[2] * src[14] + tmp[5] * src[15];
dst[9] = tmp[1] * src[12] + tmp[6] * src[14] + tmp[9] * src[15];
dst[9] -= tmp[0] * src[12] + tmp[7] * src[14] + tmp[8] * src[15];
dst[10] = tmp[2] * src[12] + tmp[7] * src[13] + tmp[10] * src[15];
dst[10] -= tmp[3] * src[12] + tmp[6] * src[13] + tmp[11] * src[15];
dst[11] = tmp[5] * src[12] + tmp[8] * src[13] + tmp[11] * src[14];
dst[11] -= tmp[4] * src[12] + tmp[9] * src[13] + tmp[10] * src[14];
dst[12] = tmp[2] * src[10] + tmp[5] * src[11] + tmp[1] * src[9];
dst[12] -= tmp[4] * src[11] + tmp[0] * src[9] + tmp[3] * src[10];
dst[13] = tmp[8] * src[11] + tmp[0] * src[8] + tmp[7] * src[10];
dst[13] -= tmp[6] * src[10] + tmp[9] * src[11] + tmp[1] * src[8];
dst[14] = tmp[6] * src[9] + tmp[11] * src[11] + tmp[3] * src[8];
dst[14] -= tmp[10] * src[11] + tmp[2] * src[8] + tmp[7] * src[9];
dst[15] = tmp[10] * src[10] + tmp[4] * src[8] + tmp[9] * src[9];
dst[15] -= tmp[8] * src[9] + tmp[11] * src[10] + tmp[5] * src[8];
// calculate determinant
float det =
src[0] * dst[0] + src[1] * dst[1] + src[2] * dst[2] + src[3]
* dst[3];
if (det == 0.0f) {
}
// calculate matrix inverse
det = 1 / det;
for (int j = 0; j < 16; j++)
mInv[j + mInvOffset] = dst[j] * det;
return true;
}
/**
* Computes an orthographic projection matrix.
*
* @param m returns the result
* @param mOffset
* @param left
* @param right
* @param bottom
* @param top
* @param near
* @param far
*/
public static void orthoM(float[] m, int mOffset,
float left, float right, float bottom, float top,
float near, float far) {
if (left == right) {
throw new IllegalArgumentException("left == right");
}
if (bottom == top) {
throw new IllegalArgumentException("bottom == top");
}
if (near == far) {
throw new IllegalArgumentException("near == far");
}
final float r_width = 1.0f / (right - left);
final float r_height = 1.0f / (top - bottom);
final float r_depth = 1.0f / (far - near);
final float x = 2.0f * (r_width);
final float y = 2.0f * (r_height);
final float z = -2.0f * (r_depth);
final float tx = -(right + left) * r_width;
final float ty = -(top + bottom) * r_height;
final float tz = -(far + near) * r_depth;
m[mOffset + 0] = x;
m[mOffset + 5] = y;
m[mOffset +10] = z;
m[mOffset +12] = tx;
m[mOffset +13] = ty;
m[mOffset +14] = tz;
m[mOffset +15] = 1.0f;
m[mOffset + 1] = 0.0f;
m[mOffset + 2] = 0.0f;
m[mOffset + 3] = 0.0f;
m[mOffset + 4] = 0.0f;
m[mOffset + 6] = 0.0f;
m[mOffset + 7] = 0.0f;
m[mOffset + 8] = 0.0f;
m[mOffset + 9] = 0.0f;
m[mOffset + 11] = 0.0f;
}
/**
* Define a projection matrix in terms of six clip planes
* @param m the float array that holds the perspective matrix
* @param offset the offset into float array m where the perspective
* matrix data is written
* @param left
* @param right
* @param bottom
* @param top
* @param near
* @param far
*/
public static void frustumM(float[] m, int offset,
float left, float right, float bottom, float top,
float near, float far) {
if (left == right) {
throw new IllegalArgumentException("left == right");
}
if (top == bottom) {
throw new IllegalArgumentException("top == bottom");
}
if (near == far) {
throw new IllegalArgumentException("near == far");
}
if (near <= 0.0f) {
throw new IllegalArgumentException("near <= 0.0f");
}
if (far <= 0.0f) {
throw new IllegalArgumentException("far <= 0.0f");
}
final float r_width = 1.0f / (right - left);
final float r_height = 1.0f / (top - bottom);
final float r_depth = 1.0f / (near - far);
final float x = 2.0f * (near * r_width);
final float y = 2.0f * (near * r_height);
final float A = 2.0f * ((right + left) * r_width);
final float B = (top + bottom) * r_height;
final float C = (far + near) * r_depth;
final float D = 2.0f * (far * near * r_depth);
m[offset + 0] = x;
m[offset + 5] = y;
m[offset + 8] = A;
m[offset + 9] = B;
m[offset + 10] = C;
m[offset + 14] = D;
m[offset + 11] = -1.0f;
m[offset + 1] = 0.0f;
m[offset + 2] = 0.0f;
m[offset + 3] = 0.0f;
m[offset + 4] = 0.0f;
m[offset + 6] = 0.0f;
m[offset + 7] = 0.0f;
m[offset + 12] = 0.0f;
m[offset + 13] = 0.0f;
m[offset + 15] = 0.0f;
}
/**
* Computes the length of a vector
*
* @param x x coordinate of a vector
* @param y y coordinate of a vector
* @param z z coordinate of a vector
* @return the length of a vector
*/
public static float length(float x, float y, float z) {
return (float) Math.sqrt(x * x + y * y + z * z);
}
/**
* Sets matrix m to the identity matrix.
* @param sm returns the result
* @param smOffset index into sm where the result matrix starts
*/
public static void setIdentityM(float[] sm, int smOffset) {
for (int i=0 ; i<16 ; i++) {
sm[smOffset + i] = 0;
}
for(int i = 0; i < 16; i += 5) {
sm[smOffset + i] = 1.0f;
}
}
/**
* Scales matrix m by x, y, and z, putting the result in sm
* @param sm returns the result
* @param smOffset index into sm where the result matrix starts
* @param m source matrix
* @param mOffset index into m where the source matrix starts
* @param x scale factor x
* @param y scale factor y
* @param z scale factor z
*/
public static void scaleM(float[] sm, int smOffset,
float[] m, int mOffset,
float x, float y, float z) {
for (int i=0 ; i<4 ; i++) {
int smi = smOffset + i;
int mi = mOffset + i;
sm[ smi] = m[ mi] * x;
sm[ 4 + smi] = m[ 4 + mi] * y;
sm[ 8 + smi] = m[ 8 + mi] * z;
sm[12 + smi] = m[12 + mi];
}
}
/**
* Scales matrix m in place by sx, sy, and sz
* @param m matrix to scale
* @param mOffset index into m where the matrix starts
* @param x scale factor x
* @param y scale factor y
* @param z scale factor z
*/
public static void scaleM(float[] m, int mOffset,
float x, float y, float z) {
for (int i=0 ; i<4 ; i++) {
int mi = mOffset + i;
m[ mi] *= x;
m[ 4 + mi] *= y;
m[ 8 + mi] *= z;
}
}
/**
* Translates matrix m by x, y, and z, putting the result in tm
* @param tm returns the result
* @param tmOffset index into sm where the result matrix starts
* @param m source matrix
* @param mOffset index into m where the source matrix starts
* @param x translation factor x
* @param y translation factor y
* @param z translation factor z
*/
public static void translateM(float[] tm, int tmOffset,
float[] m, int mOffset,
float x, float y, float z) {
for (int i=0 ; i<12 ; i++) {
tm[tmOffset + i] = m[mOffset + i];
}
for (int i=0 ; i<4 ; i++) {
int tmi = tmOffset + i;
int mi = mOffset + i;
tm[12 + tmi] = m[mi] * x + m[4 + mi] * y + m[8 + mi] * z +
m[12 + mi];
}
}
/**
* Translates matrix m by x, y, and z in place.
* @param m matrix
* @param mOffset index into m where the matrix starts
* @param x translation factor x
* @param y translation factor y
* @param z translation factor z
*/
public static void translateM(
float[] m, int mOffset,
float x, float y, float z) {
for (int i=0 ; i<4 ; i++) {
int mi = mOffset + i;
m[12 + mi] += m[mi] * x + m[4 + mi] * y + m[8 + mi] * z;
}
}
/**
* Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
* @param rm returns the result
* @param rmOffset index into rm where the result matrix starts
* @param m source matrix
* @param mOffset index into m where the source matrix starts
* @param a angle to rotate in degrees
* @param x scale factor x
* @param y scale factor y
* @param z scale factor z
*/
public static void rotateM(float[] rm, int rmOffset,
float[] m, int mOffset,
float a, float x, float y, float z) {
float[] r = new float[16];
setRotateM(r, 0, a, x, y, z);
multiplyMM(rm, rmOffset, m, mOffset, r, 0);
}
/**
* Rotates matrix m in place by angle a (in degrees)
* around the axis (x, y, z)
* @param m source matrix
* @param mOffset index into m where the matrix starts
* @param a angle to rotate in degrees
* @param x scale factor x
* @param y scale factor y
* @param z scale factor z
*/
public static void rotateM(float[] m, int mOffset,
float a, float x, float y, float z) {
float[] temp = new float[32];
setRotateM(temp, 0, a, x, y, z);
multiplyMM(temp, 16, m, mOffset, temp, 0);
System.arraycopy(temp, 16, m, mOffset, 16);
}
/**
* Rotates matrix m by angle a (in degrees) around the axis (x, y, z)
* @param rm returns the result
* @param rmOffset index into rm where the result matrix starts
* @param a angle to rotate in degrees
* @param x scale factor x
* @param y scale factor y
* @param z scale factor z
*/
public static void setRotateM(float[] rm, int rmOffset,
float a, float x, float y, float z) {
rm[rmOffset + 3] = 0;
rm[rmOffset + 7] = 0;
rm[rmOffset + 11]= 0;
rm[rmOffset + 12]= 0;
rm[rmOffset + 13]= 0;
rm[rmOffset + 14]= 0;
rm[rmOffset + 15]= 1;
a *= (float) (Math.PI / 180.0f);
float s = (float) Math.sin(a);
float c = (float) Math.cos(a);
if (1.0f == x && 0.0f == y && 0.0f == z) {
rm[rmOffset + 5] = c; rm[rmOffset + 10]= c;
rm[rmOffset + 6] = s; rm[rmOffset + 9] = -s;
rm[rmOffset + 1] = 0; rm[rmOffset + 2] = 0;
rm[rmOffset + 4] = 0; rm[rmOffset + 8] = 0;
rm[rmOffset + 0] = 1;
} else if (0.0f == x && 1.0f == y && 0.0f == z) {
rm[rmOffset + 0] = c; rm[rmOffset + 10]= c;
rm[rmOffset + 8] = s; rm[rmOffset + 2] = -s;
rm[rmOffset + 1] = 0; rm[rmOffset + 4] = 0;
rm[rmOffset + 6] = 0; rm[rmOffset + 9] = 0;
rm[rmOffset + 5] = 1;
} else if (0.0f == x && 0.0f == y && 1.0f == z) {
rm[rmOffset + 0] = c; rm[rmOffset + 5] = c;
rm[rmOffset + 1] = s; rm[rmOffset + 4] = -s;
rm[rmOffset + 2] = 0; rm[rmOffset + 6] = 0;
rm[rmOffset + 8] = 0; rm[rmOffset + 9] = 0;
rm[rmOffset + 10]= 1;
} else {
float len = length(x, y, z);
if (1.0f != len) {
float recipLen = 1.0f / len;
x *= recipLen;
y *= recipLen;
z *= recipLen;
}
float nc = 1.0f - c;
float xy = x * y;
float yz = y * z;
float zx = z * x;
float xs = x * s;
float ys = y * s;
float zs = z * s;
rm[rmOffset + 0] = x*x*nc + c;
rm[rmOffset + 4] = xy*nc - zs;
rm[rmOffset + 8] = zx*nc + ys;
rm[rmOffset + 1] = xy*nc + zs;
rm[rmOffset + 5] = y*y*nc + c;
rm[rmOffset + 9] = yz*nc - xs;
rm[rmOffset + 2] = zx*nc - ys;
rm[rmOffset + 6] = yz*nc + xs;
rm[rmOffset + 10] = z*z*nc + c;
}
}
/**
* Converts Euler angles to a rotation matrix
* @param rm returns the result
* @param rmOffset index into rm where the result matrix starts
* @param x angle of rotation, in degrees
* @param y angle of rotation, in degrees
* @param z angle of rotation, in degrees
*/
public static void setRotateEulerM(float[] rm, int rmOffset,
float x, float y, float z) {
x *= (float) (Math.PI / 180.0f);
y *= (float) (Math.PI / 180.0f);
z *= (float) (Math.PI / 180.0f);
float cx = (float) Math.cos(x);
float sx = (float) Math.sin(x);
float cy = (float) Math.cos(y);
float sy = (float) Math.sin(y);
float cz = (float) Math.cos(z);
float sz = (float) Math.sin(z);
float cxsy = cx * sy;
float sxsy = sx * sy;
rm[rmOffset + 0] = cy * cz;
rm[rmOffset + 1] = -cy * sz;
rm[rmOffset + 2] = sy;
rm[rmOffset + 3] = 0.0f;
rm[rmOffset + 4] = cxsy * cz + cx * sz;
rm[rmOffset + 5] = -cxsy * sz + cx * cz;
rm[rmOffset + 6] = -sx * cy;
rm[rmOffset + 7] = 0.0f;
rm[rmOffset + 8] = -sxsy * cz + sx * sz;
rm[rmOffset + 9] = sxsy * sz + sx * cz;
rm[rmOffset + 10] = cx * cy;
rm[rmOffset + 11] = 0.0f;
rm[rmOffset + 12] = 0.0f;
rm[rmOffset + 13] = 0.0f;
rm[rmOffset + 14] = 0.0f;
rm[rmOffset + 15] = 1.0f;
}
public void rotate(float angle, float x, float y, float z) {
Matrix.rotateM(v, 0, angle, x, y, z);
}
public void preMultiply(float[] src) {
Matrix.preMultiplyMM(v, src);
}
public void preMultiply(Matrix src) {
Matrix.preMultiplyMM(v, src.v);
}
public static void preMultiplyMMSlow(float[] dst, float[] src) {
float[] tmp = new float[16];
int i, j, k;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
int tmpIdx = 4*j+i;
tmp[tmpIdx] = 0.0f;
for (k = 0; k < 4; k++) {
tmp[tmpIdx] += src[4*k+i] * dst[4*j+k];
}
}
assign(dst, tmp);
}
public static void preMultiplyMM(float[] dst, float[] src) {
float[] tmp = new float[16];
tmp[4*0+0] = (src[0] * dst[4*0]) + (src[4+0] * dst[4*0+1]) + (src[8+0] * dst[4*0+2]) + (src[12+0] * dst[4*0+3]);
tmp[4*1+0] = (src[0] * dst[4*1]) + (src[4+0] * dst[4*1+1]) + (src[8+0] * dst[4*1+2]) + (src[12+0] * dst[4*1+3]);
tmp[4*2+0] = (src[0] * dst[4*2]) + (src[4+0] * dst[4*2+1]) + (src[8+0] * dst[4*2+2]) + (src[12+0] * dst[4*2+3]);
tmp[4*3+0] = (src[0] * dst[4*3]) + (src[4+0] * dst[4*3+1]) + (src[8+0] * dst[4*3+2]) + (src[12+0] * dst[4*3+3]);
tmp[4*0+1] = (src[1] * dst[4*0]) + (src[4+1] * dst[4*0+1]) + (src[8+1] * dst[4*0+2]) + (src[12+1] * dst[4*0+3]);
tmp[4*1+1] = (src[1] * dst[4*1]) + (src[4+1] * dst[4*1+1]) + (src[8+1] * dst[4*1+2]) + (src[12+1] * dst[4*1+3]);
tmp[4*2+1] = (src[1] * dst[4*2]) + (src[4+1] * dst[4*2+1]) + (src[8+1] * dst[4*2+2]) + (src[12+1] * dst[4*2+3]);
tmp[4*3+1] = (src[1] * dst[4*3]) + (src[4+1] * dst[4*3+1]) + (src[8+1] * dst[4*3+2]) + (src[12+1] * dst[4*3+3]);
tmp[4*0+2] = (src[2] * dst[4*0]) + (src[4+2] * dst[4*0+1]) + (src[8+2] * dst[4*0+2]) + (src[12+2] * dst[4*0+3]);
tmp[4*1+2] = (src[2] * dst[4*1]) + (src[4+2] * dst[4*1+1]) + (src[8+2] * dst[4*1+2]) + (src[12+2] * dst[4*1+3]);
tmp[4*2+2] = (src[2] * dst[4*2]) + (src[4+2] * dst[4*2+1]) + (src[8+2] * dst[4*2+2]) + (src[12+2] * dst[4*2+3]);
tmp[4*3+2] = (src[2] * dst[4*3]) + (src[4+2] * dst[4*3+1]) + (src[8+2] * dst[4*3+2]) + (src[12+2] * dst[4*3+3]);
tmp[4*0+3] = (src[3] * dst[4*0]) + (src[4+3] * dst[4*0+1]) + (src[8+3] * dst[4*0+2]) + (src[12+3] * dst[4*0+3]);
tmp[4*1+3] = (src[3] * dst[4*1]) + (src[4+3] * dst[4*1+1]) + (src[8+3] * dst[4*1+2]) + (src[12+3] * dst[4*1+3]);
tmp[4*2+3] = (src[3] * dst[4*2]) + (src[4+3] * dst[4*2+1]) + (src[8+3] * dst[4*2+2]) + (src[12+3] * dst[4*2+3]);
tmp[4*3+3] = (src[3] * dst[4*3]) + (src[4+3] * dst[4*3+1]) + (src[8+3] * dst[4*3+2]) + (src[12+3] * dst[4*3+3]);
dst[0] = tmp[0];
dst[1] = tmp[1];
dst[2] = tmp[2];
dst[3] = tmp[3];
dst[4] = tmp[4];
dst[5] = tmp[5];
dst[6] = tmp[6];
dst[7] = tmp[7];
dst[8] = tmp[8];
dst[9] = tmp[9];
dst[10] = tmp[10];
dst[11] = tmp[11];
dst[12] = tmp[12];
dst[13] = tmp[13];
dst[14] = tmp[14];
dst[15] = tmp[15];
}
public static void assign(float[] dst, float[] src) {
for (int i=0;i<16;i++)
dst[i] = src[i];
}
// column based matrix index
//#define MIDX(i, j) (4 * j + i)
} | 12anyao-esgl | esgl/src/org/esgl3d/math/Matrix.java | Java | lgpl | 25,742 |
package org.esgl3d;
import org.esgl3d.rendering.Texture;
import org.esgl3d.rendering.VertexContainer;
public class Mesh {
public enum Format {
Triangle,
TriangleStrip,
}
private VertexContainer vertices;
private int numberOfVertices;
private Format meshFormat;
private Texture texture = null;
public int getNumberOfVertices() {
return numberOfVertices;
}
public VertexContainer getVertices() {
return vertices;
}
public Format getFormat() {
return meshFormat;
}
public void setVertices(VertexContainer value, Format setMeshFormat) {
vertices = value;
numberOfVertices = value.getNumberOfVertices();
meshFormat = setMeshFormat;
}
public Texture getTexture() {
return texture;
}
public void setTexture(Texture value) {
texture = value;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/Mesh.java | Java | lgpl | 793 |
package org.esgl3d.loader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.ReadOnlyBufferException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.esgl3d.Mesh;
import org.esgl3d.Mesh.Format;
import org.esgl3d.core.ResourceResolver;
import org.esgl3d.math.Vector3d;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.VertexContainer;
import org.esgl3d.rendering.VertexFormat;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.FaceDetector.Face;
import android.util.Log;
public class ObjLoader {
private static class Float3 {
public float x;
public float y;
public float z;
}
private static class Face3 {
public int[] idx = new int[3];
public int[] tex = new int[3];
public void parseIndex(int i, String line) {
StringTokenizer tokenizer = new StringTokenizer(line, "/");
idx[i] = Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
tex[i]= Integer.parseInt(tokenizer.nextToken());
}
}
private static class Float2 {
public float u;
public float v;
}
private static class Material {
public String name = "";
public ArrayList<Face3> faces = new ArrayList<Face3>();
}
private static final Logger logger = Logger.getLogger(ObjLoader.class.getName());
private ResourceResolver resolver;
private String resourceIdString;
private final static String VERTEX = "v";
private final static String FACE = "f";
private final static String TEXCOORD = "vt";
private final static String NORMAL = "vn";
private final static String OBJECT = "o";
private final static String MATERIAL_LIB = "mtllib";
private final static String USE_MATERIAL = "usemtl";
private final static String NEW_MATERIAL = "newmtl";
private final static String DIFFUSE_TEX_MAP = "map_Kd";
private ArrayList<Float3> vertices = new ArrayList<ObjLoader.Float3>();
private ArrayList<Face3> faces = new ArrayList<ObjLoader.Face3>();
private ArrayList<Float2> texturecoords = new ArrayList<ObjLoader.Float2>();
private HashMap<String, Material> materials = new HashMap<String, Material>();
public ObjLoader(ResourceResolver res, String resourceId) {
resolver = res;
resourceIdString = resourceId;
}
public Mesh createMesh(Renderer r, InputStream stream) {
BufferedReader buffer = new BufferedReader(new InputStreamReader(resolver.getResourceStream(resourceIdString )));
String line;
Material current = null;
try {
while ((line = buffer.readLine()) != null) {
StringTokenizer parts = new StringTokenizer(line, " ");
int numTokens = parts.countTokens();
if (numTokens == 0)
continue;
String type = parts.nextToken();
if (type.equals(VERTEX)) {
if (logger.isLoggable(Level.FINEST))
logger.finest("Vertex: "+line);
Float3 f = new Float3();
f.x = Float.parseFloat(parts.nextToken());
f.y = Float.parseFloat(parts.nextToken());
f.z = Float.parseFloat(parts.nextToken());
vertices.add(f);
} else if (type.equals(FACE)) {
Face3 f = new Face3();
f.parseIndex(0,parts.nextToken());
f.parseIndex(1,parts.nextToken());
f.parseIndex(2,parts.nextToken());
faces.add(f);
current.faces.add(f);
} else if (type.equals(TEXCOORD)) {
Float2 f = new Float2();
f.u = Float.parseFloat(parts.nextToken());
f.v = Float.parseFloat(parts.nextToken());
texturecoords.add(f);
} else if (type.equals(MATERIAL_LIB)) {
parseMaterial(resolver.getResourceStream(parts.nextToken()));
} else if (type.equals(USE_MATERIAL)) {
current = materials.get(parts.nextToken());
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Mesh result = new Mesh();
VertexContainer container = null;
if (texturecoords.size() > 0)
container = r.createVertexContainer(VertexFormat.F_2Texture_3Position, faces.size()*3);
else
container = r.createVertexContainer(VertexFormat.F_4Color_3Position, faces.size()*3);
int num = 0;
for (Material mat : materials.values()) {
if (mat.name.length() > 0) {
Bitmap loadedBitmap = BitmapFactory.decodeStream(resolver.getResourceStream(mat.name));
result.setTexture(r.getTextureManager().addImage(loadedBitmap, false ));
}
for (Face3 curFace : mat.faces) {
if (logger.isLoggable(Level.FINEST))
logger.finest(String.format("Face: %d %d %d ", curFace.idx[0], curFace.idx[1], curFace.idx[2]));
if (texturecoords.size() > 0) {
foo(container, num, vertices.get(curFace.idx[0]-1), texturecoords.get(curFace.tex[0]-1));
foo(container, num+1, vertices.get(curFace.idx[1]-1),texturecoords.get(curFace.tex[1]-1));
foo(container, num+2, vertices.get(curFace.idx[2]-1),texturecoords.get(curFace.tex[2]-1));
} else {
foo(container, num, vertices.get(curFace.idx[0]-1), null);
foo(container, num+1, vertices.get(curFace.idx[1]-1),null);
foo(container, num+2, vertices.get(curFace.idx[2]-1),null);
}
num += 3;
}
}
container.synchronize();
result.setVertices(container, Format.Triangle);
return result;
}
private void foo(VertexContainer c, int idx, Float3 bar, Float2 baz) {
c.setColor(idx, 1,1,1,0.5f);
c.setPosition(idx,bar.x/1,bar.y/1,bar.z/1 );
if (baz != null)
c.setTexture(idx, baz.u, 1-baz.v);
}
private void parseMaterial(InputStream stream) {
BufferedReader buffer = new BufferedReader(new InputStreamReader(stream));
Material current = null;
String line;
try {
while ((line = buffer.readLine()) != null) {
StringTokenizer parts = new StringTokenizer(line, " ");
int numTokens = parts.countTokens();
if (numTokens == 0)
continue;
String type = parts.nextToken();
if (type.equals(NEW_MATERIAL)) {
current = new Material();
materials.put(parts.nextToken(), current);
}
if (type.equals(DIFFUSE_TEX_MAP)) {
current.name = parts.nextToken();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/loader/ObjLoader.java | Java | lgpl | 6,374 |
package org.esgl3d.primitives;
import org.esgl3d.Mesh;
import org.esgl3d.Mesh.Format;
import org.esgl3d.rendering.LegacyGLWrapper;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.VertexContainer;
import org.esgl3d.rendering.VertexFormat;
public class Box {
float box[] = new float[] {
// FRONT
0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
// BACK
-0.5f, -0.5f, -0.5f,
-0.5f, 0.5f, -0.5f,
0.5f, -0.5f, -0.5f,
0.5f, 0.5f, -0.5f,
// LEFT
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f, -0.5f, -0.5f,
-0.5f, 0.5f, -0.5f,
// RIGHT
0.5f, -0.5f, -0.5f,
0.5f, 0.5f, -0.5f,
0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
// TOP
-0.5f, 0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, -0.5f,
0.5f, 0.5f, -0.5f,
// BOTTOM
-0.5f, -0.5f, 0.5f,
-0.5f, -0.5f, -0.5f,
0.5f, -0.5f, 0.5f,
0.5f, -0.5f, -0.5f,
};
float texCoords[] = new float[] {
// FRONT
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 1.0f,
1.0f, 0.0f,
// BACK
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 1.0f,
// LEFT
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 1.0f,
// RIGHT
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 1.0f,
// TOP
0.0f, 0.0f,
1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
// BOTTOM
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 0.0f,
0.0f, 1.0f
};
VertexContainer container = null;
private Box(Renderer r) {
container = r.createVertexContainer(VertexFormat.F_2Texture_3Position, box.length/3);
//container = r.createVertexContainer(FormatType.F_4Color_3Position, box.length/3);
LegacyGLWrapper gl = container.getLegacyGLInterface();
gl.glBegin();
for (int i =0;i<box.length/3;i++) {
gl.glTexCoord2f(texCoords[i*2], texCoords[i*2+1]);
gl.glVertex3f(box[i*3]*6, box[i*3+1]*6, box[i*3+2]*6);
}
gl.glEnd();
container.synchronize();
}
public Mesh getMesh() {
Mesh m = new Mesh();
m.setVertices(container, Format.TriangleStrip);
return m;
}
public static Mesh createTexturedBox(Renderer r) {
return new Box(r).getMesh();
}
public static Mesh createTexturedBoxWithNormals(Renderer r) {
return new Box(r).getMesh();
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/primitives/Box.java | Java | lgpl | 2,273 |
package org.esgl3d.primitives;
import java.util.logging.Logger;
import org.esgl3d.Mesh;
import org.esgl3d.Mesh.Format;
import org.esgl3d.rendering.LegacyGLWrapper;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.VertexContainer;
import org.esgl3d.rendering.VertexFormat;
import org.esgl3d.rendering.VertexContainer.PrimitiveType;
public class Pyramid {
private static final Logger logger = Logger.getLogger(Pyramid.class.getName());
VertexContainer container = null;
private Pyramid(Renderer r) {
container = r.createVertexContainer(VertexFormat.F_4Color_3Position, 12);
LegacyGLWrapper gl = container.getLegacyGLInterface();
gl.glBegin();
gl.glColor4f(1,1.0f,0.0f,0.0f); // Red
gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Front)
gl.glColor4f(1,0.0f,1.0f,0.0f); // Green
gl.glVertex3f(-1.0f,-1.0f, 1.0f); // Left Of Triangle (Front)
gl.glColor4f(1,0.0f,0.0f,1.0f); // Blue
gl.glVertex3f( 1.0f,-1.0f, 1.0f); // Right Of Triangle (Front)
gl.glColor4f(1,1.0f,0.0f,0.0f); // Red
gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
gl.glColor4f(1,0.0f,0.0f,1.0f); // Blue
gl.glVertex3f( 1.0f,-1.0f, 1.0f); // Left Of Triangle (Right)
gl.glColor4f(1,0.0f,1.0f,0.0f); // Green
gl.glVertex3f( 1.0f,-1.0f, -1.0f); // Right Of Triangle (Right)
gl.glColor4f(1,1.0f,0.0f,0.0f); // Red
gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
gl.glColor4f(1,0.0f,1.0f,0.0f); // Green
gl.glVertex3f( 1.0f,-1.0f, -1.0f); // Left Of Triangle (Back)
gl.glColor4f(1,0.0f,0.0f,1.0f); // Blue
gl.glVertex3f(-1.0f,-1.0f, -1.0f); // Right Of Triangle (Back)
gl.glColor4f(1,1.0f,0.0f,0.0f); // Red
gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
gl.glColor4f(1,0.0f,0.0f,1.0f); // Blue
gl.glVertex3f(-1.0f,-1.0f,-1.0f); // Left Of Triangle (Left)
gl.glColor4f(1,0.0f,1.0f,0.0f); // Green
gl.glVertex3f(-1.0f,-1.0f, 1.0f); // Right Of Triangle (Left)
container.synchronize();
}
public Mesh getMesh() {
Mesh m = new Mesh();
m.setVertices(container, Format.Triangle);
return m;
}
public static Pyramid createColoredPyramid(Renderer r) {
return new Pyramid(r);
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/primitives/Pyramid.java | Java | lgpl | 2,431 |
package org.esgl3d.core;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import android.content.res.AssetManager;
import android.content.res.Resources;
public class AndroidResourceResolver implements ResourceResolver {
private final static Logger logger = Logger.getLogger(AndroidResourceResolver.class.getName());
private final AssetManager manager;
public AndroidResourceResolver(AssetManager setAssetManager) {
manager = setAssetManager;
}
@Override
public InputStream getResourceStream(String id) {
InputStream in = null;
if (logger.isLoggable(Level.FINE))
logger.fine("Trying resource "+id);
try {
in = manager.open(id);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return in;
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/core/AndroidResourceResolver.java | Java | lgpl | 854 |
package org.esgl3d.core;
import java.io.InputStream;
public interface ResourceResolver {
/**
* Gets a resource stream for the given filename.
* @param filename of the resource
* @return null if not found otherwise a input stream
*/
InputStream getResourceStream(String filename);
}
| 12anyao-esgl | esgl/src/org/esgl3d/core/ResourceResolver.java | Java | lgpl | 296 |
package org.esgl3d.ui;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.VertexContainer;
import org.esgl3d.rendering.VertexContainer.PrimitiveType;
import org.esgl3d.rendering.VertexFormat;
public class Label {
private VertexContainer container = null;
private String text = "";
private boolean isDirty = true;
private BitmapFont bitmapFont = null;
private int noOfVertices;
private int noOfTriangle;
private int color;
private float[] colorValuesRGBA = new float[4];
private Renderer renderer;
public Label(Renderer r) {
renderer = r;
container = renderer.createVertexContainer(VertexFormat.F_2Texture_2Position, 128);
}
public void setText(String value) {
text = value;
isDirty = true;
}
public String getText() {
return text;
}
public void setBitmapFont(BitmapFont bitmapFont) {
this.bitmapFont = bitmapFont;
isDirty = true;
}
public BitmapFont getBitmapFont() {
return bitmapFont;
}
//@ requires 0 <= \old(newColor);
//@ assignable color;
public void setColor(int newColor) {
color = newColor;
colorValuesRGBA[3] = (float)((newColor >> 24) & 0xff)/255;
colorValuesRGBA[0] = (float)((newColor >> 16) & 0xff)/255;
colorValuesRGBA[1] = (float)((newColor >> 8) & 0xff)/255;
colorValuesRGBA[2] = (float)((newColor >> 0) & 0xff)/255;
}
public int getColor() {
return color;
}
public void render(GL10 gl) {
if (isDirty) {
char[] chars = text.toCharArray();
// check if new buffer size would be different to old one
boolean bufferResize = (chars.length*2 != noOfTriangle) || (container==null);
noOfTriangle = chars.length * 2;
noOfVertices = noOfTriangle * 3;
if (bufferResize) {
/*if (container != null)
container.release();
container = renderer.createVertexContainer(VertexFormat.F_2Texture_2Position, 128);*/
} else {
}
bitmapFont.drawInBuffers(container, chars);
container.synchronize();
isDirty = false;
}
bitmapFont.bindTexture(gl);
container.draw(PrimitiveType.Triangle, 0, noOfVertices);
}
}
| 12anyao-esgl | esgl/src/org/esgl3d/ui/Label.java | Java | lgpl | 2,255 |
package org.esgl3d.ui;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import javax.microedition.khronos.opengles.GL10;
import org.esgl3d.rendering.Texture;
import org.esgl3d.rendering.VertexContainer;
import org.omg.CORBA.PRIVATE_MEMBER;
import android.graphics.Bitmap;
public class BitmapFont {
Texture fontTexture;
FloatBuffer fontTex;
FloatBuffer face;
public BitmapFont(Texture texture) {
fontTexture = texture;
float width = 1f/16f;
float height = width;
float[] fontTexCoords = new float[16*16*8];
int ix = 0;
for (int row = 0; row < 16; ++row) {
for(int col = 0; col < 16; ++col) {
fontTexCoords[ix++] = col*width;
fontTexCoords[ix++] = row*height + 0.01f;
fontTexCoords[ix++] = col*width;
fontTexCoords[ix++] = (row+1)*height - 0.01f;
fontTexCoords[ix++] = (col+1)*width;
fontTexCoords[ix++] = (row)*height + 0.01f;
fontTexCoords[ix++] = (col+1)*width;
fontTexCoords[ix++] = (row+1)*height - 0.01f;
}
}
fontTex = makeFloatBuffer(fontTexCoords);
float faceVerts[] = new float[] {
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
};
face = makeFloatBuffer(faceVerts);
}
public void bindTexture(GL10 gl) {
fontTexture.bind(gl);
}
public void drawInBuffers(VertexContainer container, char[] chars) {
for (int i = 0; i< chars.length; ++i) {
// draw two triangles for each char
// 0-2 2
// |/ /|
// 1 0-1
//vertices.put(i);
//vertices.put(0);
container.setPosition(i*6+0, i,0);
//vertices.put(i);
//vertices.put(1);
container.setPosition(i*6+1, i, 1);
//vertices.put(i+1);
//vertices.put(0);
container.setPosition(i*6+2, i+1, 0);
//vertices.put(i);
//vertices.put(1);
container.setPosition(i*6+3,i,1);
//vertices.put(i+1);
//vertices.put(1);
container.setPosition(i*6+4,i+1,1);
//vertices.put(i+1);
//vertices.put(0);
container.setPosition(i*6+5, i+1,0);
fontTex.position(chars[i]*8);
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+0, fontTex.get(),fontTex.get());
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+1, fontTex.get(),fontTex.get());
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+2, fontTex.get(),fontTex.get());
fontTex.position(chars[i]*8+2);
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+3, fontTex.get(),fontTex.get());
fontTex.position(chars[i]*8+6);
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+4, fontTex.get(),fontTex.get());
fontTex.position(chars[i]*8+4);
//texture.put(fontTex.get());
//texture.put(fontTex.get());
container.setTexture(i*6+5, fontTex.get(),fontTex.get());
}
}
/**
* Make a direct NIO FloatBuffer from an array of floats
* @param arr The array
* @return The newly created FloatBuffer
*/
protected static FloatBuffer makeFloatBuffer(float[] arr) {
ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4);
bb.order(ByteOrder.nativeOrder());
FloatBuffer fb = bb.asFloatBuffer();
fb.put(arr);
fb.position(0);
return fb;
}
/**
* Make a direct NIO IntBuffer from an array of ints
* @param arr The array
* @return The newly created IntBuffer
*/
protected static IntBuffer makeFloatBuffer(int[] arr) {
ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4);
bb.order(ByteOrder.nativeOrder());
IntBuffer ib = bb.asIntBuffer();
ib.put(arr);
ib.position(0);
return ib;
}
protected static ByteBuffer makeByteBuffer(Bitmap bmp) {
ByteBuffer bb = ByteBuffer.allocateDirect(bmp.getHeight()*bmp.getWidth()*4);
bb.order(ByteOrder.BIG_ENDIAN);
IntBuffer ib = bb.asIntBuffer();
for (int y = 0; y < bmp.getHeight(); y++)
for (int x=0;x<bmp.getWidth();x++) {
int pix = bmp.getPixel(x, bmp.getHeight()-y-1);
// Convert ARGB -> RGBA
byte alpha = (byte)((pix >> 24)&0xFF);
byte red = (byte)((pix >> 16)&0xFF);
byte green = (byte)((pix >> 8)&0xFF);
byte blue = (byte)((pix)&0xFF);
ib.put(((red&0xFF) << 24) |
((green&0xFF) << 16) |
((blue&0xFF) << 8) |
((alpha&0xFF)));
}
ib.position(0);
bb.position(0);
return bb;
}
} | 12anyao-esgl | esgl/src/org/esgl3d/ui/BitmapFont.java | Java | lgpl | 4,477 |
package org.esgl3d;
import java.util.ArrayList;
import java.util.List;
import org.esgl3d.core.AndroidResourceResolver;
import org.esgl3d.loader.ObjLoader;
import org.esgl3d.primitives.Pyramid;
import org.esgl3d.rendering.RenderActivity;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.scene.MeshNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.ui.BitmapFont;
import org.esgl3d.ui.Label;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
import android.view.MotionEvent;
public class ExAsteroidChaseActivity extends RenderActivity implements SensorEventListener {
private static final int MAX_ASTEROIDS = 15;
private MeshNode parentNode;
private Label myLabel;
private Renderer cur;
private int oldFps;
private ArrayList<MeshNode> asteroids = new ArrayList<MeshNode>();
private Mesh asteroidMesh;
private Scene myScene;
private ArrayList<MeshNode> kill = new ArrayList<MeshNode>();
private Mesh pyramid;
private float deltaX = 0;
private float deltaY = 0;
private float centerX = 0;
private float centerY = 30;
private boolean centered = false;
private Vibrator vibrator = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
}
@Override
protected void onStart() {
super.onStart();
SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensorList = sm.getSensorList(Sensor.TYPE_ORIENTATION);
sm.registerListener(this, sensorList.get(0) , SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onPause() {
super.onPause();
SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
sm.unregisterListener(this);
}
@Override
public void setupScenegraph() {
cur = getRenderer();
myScene = new Scene();
// add our first pyramid
parentNode = new MeshNode();
pyramid = Pyramid.createColoredPyramid(cur).getMesh();
parentNode.setGeometry(pyramid);
parentNode.translate(0, 0, -10);
parentNode.rotate(180, 0, 1, 0);
//parentNode.rotate(90, 1, 0, 0);
// create a second pyramid and attach it to the base with
// a offset to the right (x)
AndroidResourceResolver resolver = new AndroidResourceResolver(getAssets());
ObjLoader loader = new ObjLoader(resolver,"comet.obj");
asteroidMesh = loader.createMesh(cur, null);
loader = new ObjLoader(resolver, "starship.obj");
Mesh starshipMesh = loader.createMesh(cur, null);
parentNode.setGeometry(starshipMesh);
// add the first node to our scene (obviously the child pyramid is
// attached too)
myScene.addChild(parentNode);
// set our scene as the one to render
cur.setScene(myScene);
Options opt = new Options();
opt.inPreferredConfig = Config.RGB_565;
Bitmap font = BitmapFactory.decodeStream(resolver.getResourceStream("font.png"));
BitmapFont bmpFont = new BitmapFont(cur.getTextureManager().addImage(font, true));
myLabel = new Label(cur);
myLabel.setBitmapFont(bmpFont);
}
@Override
public void updateScenegraph() {
// rotate the parent node
//parentNode.rotate(0.50f, 0, 1, 0);
cur.setOrthographicProjection();
if (cur.getFpsCounter().getLastFps() != oldFps) {
oldFps = cur.getFpsCounter().getLastFps();
myLabel.setText(cur.getFpsCounter().toString() + " " + String.valueOf(asteroids.size()));
}
myLabel.setColor(Color.WHITE);
myLabel.render(cur.getGl());
if ( (asteroids.size() < MAX_ASTEROIDS) && (Math.random() <= 0.05) ) {
MeshNode childNode = new MeshNode();
childNode.setGeometry(asteroidMesh);
childNode.translate((float)Math.random()*30-15, (float)Math.random()*30-15, -600);
myScene.addChild(childNode);
asteroids.add(childNode);
}
kill.clear();
for (MeshNode curAsteroid : asteroids) {
curAsteroid.translate(0,0,125f * cur.getFpsCounter().getLastDelta() / 1000);
org.esgl3d.math.Matrix local = curAsteroid.getLocalTransformation();
if ( (local.v[14] >= -15) && (local.v[14] <= -5) ) {
float dx = local.v[12] - parentNode.getLocalTransformation().v[12];
float dy = local.v[13] - parentNode.getLocalTransformation().v[13];
//float dz = local.v[14] - parentNode.getLocalTransformation().v[14];
float distance = (float)Math.sqrt((dx*dx)+(dy*dy));
if (distance <= 5)
vibrator.vibrate(100);
}
if (local.v[14] > 2)
kill.add(curAsteroid);
}
for (MeshNode cur : kill) {
myScene.removeChild(cur);
asteroids.remove(cur);
}
if (centered) {
final float max = 25;
float dX = (deltaX-centerX);
float dY = (deltaY-centerY);
if (dX < -max)
dX = -max;
if (dX > max)
dX = max;
if (dY < -max)
dY = -max;
if (dY > max)
dY = max;
parentNode.translate(0.5f*dX*cur.getFpsCounter().getLastDelta()/1000, 0 ,0);
parentNode.translate(0, 0.5f*dY*cur.getFpsCounter().getLastDelta()/1000,0);
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
@Override
public boolean onTouchEvent(MotionEvent event) {
centerX = deltaX;
centerY = deltaY;
centered = true;
return true;
}
@Override
public void onSensorChanged(SensorEvent event) {
//Log.d("sensor1", String.valueOf(event.values[1]));
//Log.d("sensor2", String.valueOf(event.values[2]));
deltaX = event.values[2];
deltaY = event.values[1];
}
}
| 12anyao-esgl | esgl-demo/src/org/esgl3d/ExAsteroidChaseActivity.java | Java | lgpl | 5,922 |
package org.esgl3d;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
import android.app.Activity;
import android.os.Bundle;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.util.Linkify;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.AdapterContextMenuInfo;
/**
* Main menu activity
*
* @author Lee
*/
public class Startup extends ListActivity
{
private final int CONTEXTID_VIEWFILE = 0;
private final int CONTEXTID_CANCEL = 1;
private Class<?>[] classes = {
ExMinimalActivity.class,
ExTexturedBoxActivity.class,
ExBitmapFontActivity.class,
ExAsteroidChaseActivity.class,
};
private String[] strings = {
"Two spinning pyramids",
"A textured box",
"Simple bitmap font (displays fps)",
"Asteroid chase (sample game)"
};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InputStream logFile = getResources().openRawResource(R.raw.logging);
try {
LogManager.getLogManager().readConfiguration(logFile);
LogCatHandler handler = new LogCatHandler();
handler.setLevel(java.util.logging.Level.ALL);
LogManager.getLogManager().getLogger("").addHandler(handler);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strings));
registerForContextMenu(getListView());
}
@Override
public void onListItemClick(ListView parent, View v, int position, long id)
{
this.startActivity( new Intent(this, classes[position] ) );
}
}
| 12anyao-esgl | esgl-demo/src/org/esgl3d/Startup.java | Java | lgpl | 2,063 |
package org.esgl3d;
import java.util.Date;
import org.esgl3d.core.AndroidResourceResolver;
import org.esgl3d.primitives.Box;
import org.esgl3d.rendering.RenderActivity;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.rendering.TextureManager;
import org.esgl3d.scene.MeshNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.ui.BitmapFont;
import org.esgl3d.ui.Label;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
public class ExBitmapFontActivity extends RenderActivity {
private Label myLabel = null;
private Renderer cur;
private MeshNode box = null;
private final String dateTime;
private int oldFps;
public ExBitmapFontActivity() {
dateTime = new Date().toLocaleString();
}
@Override
public void setupScenegraph() {
cur = getRenderer();
// create a new scene
Scene myScene = new Scene();
Mesh boxMesh = Box.createTexturedBox(cur);
AndroidResourceResolver resolver = new AndroidResourceResolver(getAssets());
Bitmap font = BitmapFactory.decodeStream(resolver.getResourceStream("nehe_texture_crate.png"));
// create a new box and set a texture
box = new MeshNode();
box.setGeometry(boxMesh);
boxMesh.setTexture(cur.getTextureManager().addImage(font, false));
// add the box to the scene
myScene.addChild(box);
// set the scene to be rendered
cur.setScene(myScene);
Options opt = new Options();
opt.inPreferredConfig = Config.RGB_565;
font = BitmapFactory.decodeStream(resolver.getResourceStream("font.png"));
BitmapFont bmpFont = new BitmapFont(cur.getTextureManager().addImage(font, true));
myLabel = new Label(cur);
myLabel.setBitmapFont(bmpFont);
}
@Override
public void updateScenegraph() {
// rotate our box a little
box.rotate(1, 0.25f, 1, 0);
cur.setOrthographicProjection();
if (cur.getFpsCounter().getLastFps() != oldFps) {
oldFps = cur.getFpsCounter().getLastFps();
}
myLabel.setText(cur.getFpsCounter().toString());
myLabel.setColor(Color.WHITE);
myLabel.render(cur.getGl());
}
}
| 12anyao-esgl | esgl-demo/src/org/esgl3d/ExBitmapFontActivity.java | Java | lgpl | 2,191 |
package org.esgl3d;
import org.esgl3d.primitives.Pyramid;
import org.esgl3d.rendering.RenderActivity;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.scene.MeshNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.scene.SceneNode;
import android.app.Activity;
import android.os.Bundle;
public class ExMinimalActivity extends RenderActivity {
private MeshNode parentNode;
private MeshNode childNode;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public void setupScenegraph() {
// get our current renderer instance
Renderer cur = getRenderer();
// create a new scene
Scene myScene = new Scene();
// add our first pyramid
parentNode = new MeshNode();
parentNode.setGeometry(Pyramid.createColoredPyramid(cur).getMesh());
// create a second pyramid and attach it to the base with
// a offset to the right (x)
childNode = new MeshNode();
childNode.setGeometry(Pyramid.createColoredPyramid(cur).getMesh());
childNode.translate(10, 0, 0);
childNode.attachTo(parentNode);
// add the first node to our scene (obviously the child pyramid is
// attached too)
myScene.addChild(parentNode);
// set our scene as the one to render
cur.setScene(myScene);
}
@Override
public void updateScenegraph() {
// rotate the parent node
parentNode.rotate(1, 0, 1, 0);
// rotate the child node
// since this node is attached to the parent it gets rotated too
childNode.rotate(1, 0, 0, 1);
}
}
| 12anyao-esgl | esgl-demo/src/org/esgl3d/ExMinimalActivity.java | Java | lgpl | 1,568 |
package org.esgl3d;
import org.esgl3d.core.AndroidResourceResolver;
import org.esgl3d.primitives.Box;
import org.esgl3d.primitives.Pyramid;
import org.esgl3d.rendering.RenderActivity;
import org.esgl3d.rendering.Renderer;
import org.esgl3d.scene.MeshNode;
import org.esgl3d.scene.Scene;
import org.esgl3d.ui.BitmapFont;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.os.Bundle;
public class ExTexturedBoxActivity extends RenderActivity {
private MeshNode box;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public void setupScenegraph() {
AndroidResourceResolver resolver = new AndroidResourceResolver(getAssets());
// get our renderer
Renderer cur = getRenderer();
// load a bitmap (straightforward android code)
Options opt = new Options();
opt.inPreferredConfig = Config.RGB_565;
Bitmap font = BitmapFactory.decodeStream(resolver.getResourceStream("nehe_texture_crate.png"));
// create a new scene
Scene myScene = new Scene();
Mesh boxMesh = Box.createTexturedBox(cur);
// create a new box and set a texture
box = new MeshNode();
box.setGeometry(boxMesh);
boxMesh.setTexture(cur.getTextureManager().addImage(font, false));
// add the box to the scene
myScene.addChild(box);
// set the scene to be rendered
cur.setScene(myScene);
}
@Override
public void updateScenegraph() {
// rotate our box a little
box.rotate(1, 0.25f, 1, 0);
}
}
| 12anyao-esgl | esgl-demo/src/org/esgl3d/ExTexturedBoxActivity.java | Java | lgpl | 1,656 |
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>${className} List</title>
</head>
<body>
<div class="nav">
<span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
<span class="menuButton"><g:link class="create" action="create">New ${className}</g:link></span>
</div>
<div class="body">
<h1>${className} List</h1>
<g:if test="\${flash.message}">
<div class="message">\${flash.message}</div>
</g:if>
<div class="list">
<table>
<thead>
<tr>
<%
excludedProps = ['version',
'onLoad',
'beforeInsert',
'beforeDelete',
'beforeUpdate',
'afterInsert',
'afterUpdate',
'afterDelete']
props = domainClass.properties.findAll { !excludedProps.contains(it.name) && it.type != Set.class }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.eachWithIndex { p,i ->
if(i < 6) {
if(p.isAssociation()) { %>
<th>${p.naturalName}</th>
<% } else { %>
<g:sortableColumn property="${p.name}" title="${p.naturalName}" />
<% } } } %>
</tr>
</thead>
<tbody>
<g:each in="\${${propertyName}List}" status="i" var="${propertyName}">
<tr class="\${(i % 2) == 0 ? 'odd' : 'even'}">
<% props.eachWithIndex { p,i ->
if(i == 0) { %>
<td><g:link action="show" id="\${${propertyName}.id}">\${fieldValue(bean:${propertyName}, field:'${p.name}')}</g:link></td>
<% } else if(i < 6) { %>
<td>\${fieldValue(bean:${propertyName}, field:'${p.name}')}</td>
<% } } %>
</tr>
</g:each>
</tbody>
</table>
</div>
<div class="paginateButtons">
<g:paginate total="\${${propertyName}Total}" />
</div>
</div>
</body>
</html>
| 0auf21 | trunk/0auf21/src/templates/scaffolding/list.gsp | Groovy Server Pages | bsd | 2,787 |
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>Show ${className}</title>
</head>
<body>
<div class="nav">
<span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
<span class="menuButton"><g:link class="list" action="list">${className} List</g:link></span>
<span class="menuButton"><g:link class="create" action="create">New ${className}</g:link></span>
</div>
<div class="body">
<h1>Show ${className}</h1>
<g:if test="\${flash.message}">
<div class="message">\${flash.message}</div>
</g:if>
<div class="dialog">
<table>
<tbody>
<%
excludedProps = ['version',
'onLoad',
'beforeInsert',
'beforeDelete',
'beforeUpdate',
'afterInsert',
'afterUpdate',
'afterDelete']
props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.each { p -> %>
<tr class="prop">
<td valign="top" class="name">${p.naturalName}:</td>
<% if(p.isEnum()) { %>
<td valign="top" class="value">\${${propertyName}?.${p.name}?.encodeAsHTML()}</td>
<% } else if(p.oneToMany || p.manyToMany) { %>
<td valign="top" style="text-align:left;" class="value">
<ul>
<g:each var="${p.name[0]}" in="\${${propertyName}.${p.name}}">
<li><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${p.name[0]}.id}">\${${p.name[0]}?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
</td>
<% } else if(p.manyToOne || p.oneToOne) { %>
<td valign="top" class="value"><g:link controller="${p.referencedDomainClass?.propertyName}" action="show" id="\${${propertyName}?.${p.name}?.id}">\${${propertyName}?.${p.name}?.encodeAsHTML()}</g:link></td>
<% } else { %>
<td valign="top" class="value">\${fieldValue(bean:${propertyName}, field:'${p.name}')}</td>
<% } %>
</tr>
<% } %>
</tbody>
</table>
</div>
<div class="buttons">
<g:form>
<input type="hidden" name="id" value="\${${propertyName}?.id}" />
<span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
<span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
</g:form>
</div>
</div>
</body>
</html>
| 0auf21 | trunk/0auf21/src/templates/scaffolding/show.gsp | Groovy Server Pages | bsd | 3,368 |
<%=packageName ? "package ${packageName}\n\n" : ''%>import com.google.appengine.api.datastore.*
class ${className}Controller {
def persistenceManager
def index = { redirect(action:list,params:params) }
// the delete, save and update actions only accept POST requests
static allowedMethods = [delete:'POST', save:'POST', update:'POST']
def list = {
params.max = Math.min( params.max ? params.max.toInteger() : 10, 100)
def query = persistenceManager.newQuery( ${className} )
def ${propertyName}List = query.execute()
def total = 0
if( ${propertyName}List && ${propertyName}List.size() > 0){
total = ${propertyName}List.size()
}
[ ${propertyName}List : ${propertyName}List, ${propertyName}Total: total ]
}
def show = {
def ${propertyName} = persistenceManager.getObjectById( ${className}.class, Long.parseLong( params.id ) )
if(!${propertyName}) {
flash.message = "${className} not found with id \${params.id}"
redirect(action:list)
}
else { return [ ${propertyName} : ${propertyName} ] }
}
def delete = {
def ${propertyName} = persistenceManager.getObjectById( ${className}.class, Long.parseLong( params.id ) )
if(${propertyName}) {
try {
persistenceManager.deletePersistent(${propertyName})
flash.message = "${className} \${params.id} deleted"
redirect(action:list)
}
catch(Exception e) {
flash.message = "${className} \${params.id} could not be deleted"
redirect(action:show,id:params.id)
}
}
else {
flash.message = "${className} not found with id \${params.id}"
redirect(action:list)
}
}
def edit = {
def ${propertyName} = persistenceManager.getObjectById( ${className}.class, Long.parseLong( params.id ) )
if(!${propertyName}) {
flash.message = "${className} not found with id \${params.id}"
redirect(action:list)
}
else {
${propertyName} = persistenceManager.detachCopy( ${propertyName} )
return [ ${propertyName} : ${propertyName} ]
}
}
def update = {
def ${propertyName} = persistenceManager.getObjectById( ${className}.class, Long.parseLong( params.id ) )
if(${propertyName}) {
${propertyName}.properties = params
if(!${propertyName}.hasErrors()){
try{
persistenceManager.makePersistent(${propertyName})
} catch( Exception e ){
render(view:'edit',model:[${propertyName}:${propertyName}])
}finally{
flash.message = "${className} \${params.id} updated"
redirect(action:show,id:${propertyName}.id)
}
}
else {
render(view:'edit',model:[${propertyName}:${propertyName}])
}
}
else {
flash.message = "${className} not found with id \${params.id}"
redirect(action:list)
}
}
def create = {
def ${propertyName} = new ${className}()
${propertyName}.properties = params
return ['${propertyName}':${propertyName}]
}
def save = {
def ${propertyName} = new ${className}(params)
if(!${propertyName}.hasErrors() ) {
try{
persistenceManager.makePersistent(${propertyName})
} finally{
flash.message = "${className} \${${propertyName}.id} created"
redirect(action:show,id:${propertyName}.id)
}
}
render(view:'create',model:[${propertyName}:${propertyName}])
}
}
| 0auf21 | trunk/0auf21/src/templates/scaffolding/Controller.groovy | Groovy | bsd | 3,643 |
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>Create ${className}</title>
</head>
<body>
<div class="nav">
<span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
<span class="menuButton"><g:link class="list" action="list">${className} List</g:link></span>
</div>
<div class="body">
<h1>Create ${className}</h1>
<g:if test="\${flash.message}">
<div class="message">\${flash.message}</div>
</g:if>
<g:hasErrors bean="\${${propertyName}}">
<div class="errors">
<g:renderErrors bean="\${${propertyName}}" as="list" />
</div>
</g:hasErrors>
<g:form action="save" method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
<div class="dialog">
<table>
<tbody>
<%
excludedProps = ['version',
'id',
'onLoad',
'beforeInsert',
'beforeDelete',
'beforeUpdate',
'afterInsert',
'afterUpdate',
'afterDelete']
props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.each { p ->
if(!Collection.class.isAssignableFrom(p.type)) {
cp = domainClass.constrainedProperties[p.name]
display = (cp ? cp.display : true)
if(display) { %>
<tr class="prop">
<td valign="top" class="name">
<label for="${p.name}">${p.naturalName}:</label>
</td>
<td valign="top" class="value \${hasErrors(bean:${propertyName},field:'${p.name}','errors')}">
${renderEditor(p)}
</td>
</tr>
<% } } } %>
</tbody>
</table>
</div>
<div class="buttons">
<span class="button"><input class="save" type="submit" value="Create" /></span>
</div>
</g:form>
</div>
</body>
</html>
| 0auf21 | trunk/0auf21/src/templates/scaffolding/create.gsp | Groovy Server Pages | bsd | 2,832 |
<%=packageName%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>Edit ${className}</title>
</head>
<body>
<div class="nav">
<span class="menuButton"><a class="home" href="\${resource(dir:'')}">Home</a></span>
<span class="menuButton"><g:link class="list" action="list">${className} List</g:link></span>
<span class="menuButton"><g:link class="create" action="create">New ${className}</g:link></span>
</div>
<div class="body">
<h1>Edit ${className}</h1>
<g:if test="\${flash.message}">
<div class="message">\${flash.message}</div>
</g:if>
<g:hasErrors bean="\${${propertyName}}">
<div class="errors">
<g:renderErrors bean="\${${propertyName}}" as="list" />
</div>
</g:hasErrors>
<g:form method="post" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
<input type="hidden" name="id" value="\${${propertyName}?.id}" />
<input type="hidden" name="version" value="\${${propertyName}?.version}" />
<div class="dialog">
<table>
<tbody>
<%
excludedProps = ['version',
'id',
'onLoad',
'beforeInsert',
'beforeDelete',
'beforeUpdate',
'afterInsert',
'afterUpdate',
'afterDelete']
props = domainClass.properties.findAll { !excludedProps.contains(it.name) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.each { p ->
cp = domainClass.constrainedProperties[p.name]
display = (cp ? cp.display : true)
if(display) { %>
<tr class="prop">
<td valign="top" class="name">
<label for="${p.name}">${p.naturalName}:</label>
</td>
<td valign="top" class="value \${hasErrors(bean:${propertyName},field:'${p.name}','errors')}">
${renderEditor(p)}
</td>
</tr>
<% } } %>
</tbody>
</table>
</div>
<div class="buttons">
<span class="button"><g:actionSubmit class="save" value="Update" /></span>
<span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
</div>
</g:form>
</div>
</body>
</html>
| 0auf21 | trunk/0auf21/src/templates/scaffolding/edit.gsp | Groovy Server Pages | bsd | 3,135 |
@artifact.package@
import javax.jdo.annotations.*;
// import com.google.appengine.api.datastore.Key;
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
class @artifact.name@ implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Long id
@Persistent
String property1
static constraints = {
id( visible:false)
}
}
| 0auf21 | trunk/0auf21/src/templates/artifacts/DomainClass.groovy | Groovy | bsd | 405 |
<!DOCTYPE html>
<html>
<head>
<title><g:layoutTitle default="Grails" /></title>
<link rel="stylesheet" href="${resource(dir:'css',file:'main.css')}" />
<link rel="shortcut icon" href="${resource(dir:'images',file:'favicon.ico')}" type="image/x-icon" />
<g:layoutHead />
<g:javascript library="application" />
</head>
<body>
<div id="spinner" class="spinner" style="display:none;">
<img src="${resource(dir:'images',file:'spinner.gif')}" alt="${message(code:'spinner.alt',default:'Loading...')}" />
</div>
<div id="grailsLogo"><a href="http://grails.org"><img src="${resource(dir:'images',file:'grails_logo.png')}" alt="Grails" border="0" /></a></div>
<g:layoutBody />
</body>
</html> | 0auf21 | trunk/0auf21/grails-app/views/layouts/main.gsp | Groovy Server Pages | bsd | 783 |
<html>
<head>
<title>Grails Runtime Exception</title>
<style type="text/css">
.message {
border: 1px solid black;
padding: 5px;
background-color:#E9E9E9;
}
.stack {
border: 1px solid black;
padding: 5px;
overflow:auto;
height: 300px;
}
.snippet {
padding: 5px;
background-color:white;
border:1px solid black;
margin:3px;
font-family:courier;
}
</style>
</head>
<body>
<h1>Grails Runtime Exception</h1>
<h2>Error Details</h2>
<div class="message">
<strong>Error ${request.'javax.servlet.error.status_code'}:</strong> ${request.'javax.servlet.error.message'.encodeAsHTML()}<br/>
<strong>Servlet:</strong> ${request.'javax.servlet.error.servlet_name'}<br/>
<strong>URI:</strong> ${request.'javax.servlet.error.request_uri'}<br/>
<g:if test="${exception}">
<strong>Exception Message:</strong> ${exception.message?.encodeAsHTML()} <br />
<strong>Caused by:</strong> ${exception.cause?.message?.encodeAsHTML()} <br />
<strong>Class:</strong> ${exception.className} <br />
<strong>At Line:</strong> [${exception.lineNumber}] <br />
<strong>Code Snippet:</strong><br />
<div class="snippet">
<g:each var="cs" in="${exception.codeSnippet}">
${cs?.encodeAsHTML()}<br />
</g:each>
</div>
</g:if>
</div>
<g:if test="${exception}">
<h2>Stack Trace</h2>
<div class="stack">
<pre><g:each in="${exception.stackTraceLines}">${it.encodeAsHTML()}<br/></g:each></pre>
</div>
</g:if>
</body>
</html> | 0auf21 | trunk/0auf21/grails-app/views/error.gsp | Groovy Server Pages | bsd | 1,601 |
<html>
<head>
<title>Welcome to Grails</title>
<meta name="layout" content="main" />
<style type="text/css" media="screen">
#nav {
margin-top:20px;
margin-left:30px;
width:228px;
float:left;
}
.homePagePanel * {
margin:0px;
}
.homePagePanel .panelBody ul {
list-style-type:none;
margin-bottom:10px;
}
.homePagePanel .panelBody h1 {
text-transform:uppercase;
font-size:1.1em;
margin-bottom:10px;
}
.homePagePanel .panelBody {
background: url(images/leftnav_midstretch.png) repeat-y top;
margin:0px;
padding:15px;
}
.homePagePanel .panelBtm {
background: url(images/leftnav_btm.png) no-repeat top;
height:20px;
margin:0px;
}
.homePagePanel .panelTop {
background: url(images/leftnav_top.png) no-repeat top;
height:11px;
margin:0px;
}
h2 {
margin-top:15px;
margin-bottom:15px;
font-size:1.2em;
}
#pageBody {
margin-left:280px;
margin-right:20px;
}
</style>
</head>
<body>
<div id="nav">
<div class="homePagePanel">
<div class="panelTop"></div>
<div class="panelBody">
<h1>Application Status</h1>
<ul>
<li>App version: <g:meta name="app.version"></g:meta></li>
<li>Grails version: <g:meta name="app.grails.version"></g:meta></li>
<li>Groovy version: ${org.codehaus.groovy.runtime.InvokerHelper.getVersion()}</li>
<li>JVM version: ${System.getProperty('java.version')}</li>
<li>Controllers: ${grailsApplication.controllerClasses.size()}</li>
<li>Domains: ${grailsApplication.domainClasses.size()}</li>
<li>Services: ${grailsApplication.serviceClasses.size()}</li>
<li>Tag Libraries: ${grailsApplication.tagLibClasses.size()}</li>
</ul>
<h1>Installed Plugins</h1>
<ul>
<g:set var="pluginManager"
value="${applicationContext.getBean('pluginManager')}"></g:set>
<g:each var="plugin" in="${pluginManager.allPlugins}">
<li>${plugin.name} - ${plugin.version}</li>
</g:each>
</ul>
</div>
<div class="panelBtm"></div>
</div>
</div>
<div id="pageBody">
<h1>Welcome to Grails</h1>
<p>Congratulations, you have successfully started your first Grails application! At the moment
this is the default page, feel free to modify it to either redirect to a controller or display whatever
content you may choose. Below is a list of controllers that are currently deployed in this application,
click on each to execute its default action:</p>
<div id="controllerList" class="dialog">
<h2>Available Controllers:</h2>
<ul>
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
</g:each>
</ul>
</div>
</div>
</body>
</html>
| 0auf21 | trunk/0auf21/grails-app/views/index.gsp | Groovy Server Pages | bsd | 3,867 |
package de.cecube.v0a21.domain
class Activity {
static constraints = {
}
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Activity.groovy | Groovy | bsd | 85 |
package de.cecube.v0a21.domain
class Goal {
static constraints = {
}
Date from
Date until
Integer maxDistance
Integer maxTime
Integer runningTime
Integer walkingTime
Integer repititions
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Goal.groovy | Groovy | bsd | 236 |
package de.cecube.v0a21.domain
class Group {
static constraints = {
}
String name
Double distance
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Group.groovy | Groovy | bsd | 123 |
package de.cecube.v0a21.domain
class Trainee extends Runner{
static constraints = {
}
Season season
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Trainee.groovy | Groovy | bsd | 121 |
package de.cecube.v0a21.domain
class Season {
static constraints = {
}
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Season.groovy | Groovy | bsd | 83 |
package de.cecube.v0a21.domain
class Runner {
static constraints = {
}
String surName
String firstName
String email
String telephone
Group group
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Runner.groovy | Groovy | bsd | 182 |
package de.cecube.v0a21.domain
class Trainer extends Runner {
static constraints = {
}
}
| 0auf21 | trunk/0auf21/grails-app/domain/de/cecube/v0a21/domain/Trainer.groovy | Groovy | bsd | 99 |
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
//mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.13'
}
}
| 0auf21 | trunk/0auf21/grails-app/conf/BuildConfig.groovy | Groovy | bsd | 1,185 |
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts
// grails.config.locations = [ "classpath:${appName}-config.properties",
// "classpath:${appName}-config.groovy",
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.use.accept.header = false
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml'],
text: 'text/plain',
js: 'text/javascript',
rss: 'application/rss+xml',
atom: 'application/atom+xml',
css: 'text/css',
csv: 'text/csv',
all: '*/*',
json: ['application/json','text/json'],
form: 'application/x-www-form-urlencoded',
multipartForm: 'multipart/form-data'
]
// URL Mapping Cache Max Size, defaults to 5000
//grails.urlmapping.cache.maxsize = 1000
// The default codec used to encode data with ${}
grails.views.default.codec = "none" // none, html, base64
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
// enable Sitemesh preprocessing of GSP pages
grails.views.gsp.sitemesh.preprocess = true
// scaffolding templates configuration
grails.scaffolding.templates.domainSuffix = 'Instance'
// Set to false to use the new Grails 1.2 JSONBuilder in the render method
grails.json.legacy.builder = false
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
// whether to install the java.util.logging bridge for sl4j. Disable for AppEngine!
grails.logging.jul.usebridge = true
// packages to include in Spring bean scanning
grails.spring.bean.packages = []
// request parameters to mask when logging exceptions
grails.exceptionresolver.params.exclude = ['password']
// set per-environment serverURL stem for creating absolute links
environments {
production {
grails.serverURL = "http://www.changeme.com"
}
development {
grails.serverURL = "http://localhost:8080/${appName}"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
}
// log4j configuration
log4j = {
// Example of changing the log pattern for the default console
// appender:
//
//appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
//}
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
warn 'org.mortbay.log'
}
| 0auf21 | trunk/0auf21/grails-app/conf/Config.groovy | Groovy | bsd | 3,736 |
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(view:"/index")
"500"(view:'/error')
}
}
| 0auf21 | trunk/0auf21/grails-app/conf/UrlMappings.groovy | Groovy | bsd | 180 |
// Place your Spring DSL code here
beans = {
}
| 0auf21 | trunk/0auf21/grails-app/conf/spring/resources.groovy | Groovy | bsd | 47 |
dataSource {
pooled = true
driverClassName = "org.hsqldb.jdbcDriver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:hsqldb:mem:devDB"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:mem:testDb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:file:prodDb;shutdown=true"
}
}
}
| 0auf21 | trunk/0auf21/grails-app/conf/DataSource.groovy | Groovy | bsd | 768 |
class BootStrap {
def init = { servletContext ->
}
def destroy = {
}
}
| 0auf21 | trunk/0auf21/grails-app/conf/BootStrap.groovy | Groovy | bsd | 88 |
var Ajax;
if (Ajax && (Ajax != null)) {
Ajax.Responders.register({
onCreate: function() {
if($('spinner') && Ajax.activeRequestCount>0)
Effect.Appear('spinner',{duration:0.5,queue:'end'});
},
onComplete: function() {
if($('spinner') && Ajax.activeRequestCount==0)
Effect.Fade('spinner',{duration:0.5,queue:'end'});
}
});
}
| 0auf21 | trunk/0auf21/web-app/js/application.js | JavaScript | bsd | 373 |
html * {
margin: 0;
/*padding: 0; SELECT NOT DISPLAYED CORRECTLY IN FIREFOX */
}
/* GENERAL */
.spinner {
padding: 5px;
position: absolute;
right: 0;
}
body {
background: #fff;
color: #333;
font: 11px verdana, arial, helvetica, sans-serif;
}
#grailsLogo {
padding:20px;
}
a:link, a:visited, a:hover {
color: #666;
font-weight: bold;
text-decoration: none;
}
h1 {
color: #48802c;
font-weight: normal;
font-size: 16px;
margin: .8em 0 .3em 0;
}
ul {
padding-left: 15px;
}
input, select, textarea {
background-color: #fcfcfc;
border: 1px solid #ccc;
font: 11px verdana, arial, helvetica, sans-serif;
margin: 2px 0;
padding: 2px 4px;
}
select {
padding: 2px 2px 2px 0;
}
textarea {
width: 250px;
height: 150px;
vertical-align: top;
}
input:focus, select:focus, textarea:focus {
border: 1px solid #b2d1ff;
}
.body {
float: left;
margin: 0 15px 10px 15px;
}
/* NAVIGATION MENU */
.nav {
background: #fff url(../images/skin/shadow.jpg) bottom repeat-x;
border: 1px solid #ccc;
border-style: solid none solid none;
margin-top: 5px;
padding: 7px 12px;
}
.menuButton {
font-size: 10px;
padding: 0 5px;
}
.menuButton a {
color: #333;
padding: 4px 6px;
}
.menuButton a.home {
background: url(../images/skin/house.png) center left no-repeat;
color: #333;
padding-left: 25px;
}
.menuButton a.list {
background: url(../images/skin/database_table.png) center left no-repeat;
color: #333;
padding-left: 25px;
}
.menuButton a.create {
background: url(../images/skin/database_add.png) center left no-repeat;
color: #333;
padding-left: 25px;
}
/* MESSAGES AND ERRORS */
.message {
background: #f3f8fc url(../images/skin/information.png) 8px 50% no-repeat;
border: 1px solid #b2d1ff;
color: #006dba;
margin: 10px 0 5px 0;
padding: 5px 5px 5px 30px
}
div.errors {
background: #fff3f3;
border: 1px solid red;
color: #cc0000;
margin: 10px 0 5px 0;
padding: 5px 0 5px 0;
}
div.errors ul {
list-style: none;
padding: 0;
}
div.errors li {
background: url(../images/skin/exclamation.png) 8px 0% no-repeat;
line-height: 16px;
padding-left: 30px;
}
td.errors select {
border: 1px solid red;
}
td.errors input {
border: 1px solid red;
}
td.errors textarea {
border: 1px solid red;
}
/* TABLES */
table {
border: 1px solid #ccc;
width: 100%
}
tr {
border: 0;
}
td, th {
font: 11px verdana, arial, helvetica, sans-serif;
line-height: 12px;
padding: 5px 6px;
text-align: left;
vertical-align: top;
}
th {
background: #fff url(../images/skin/shadow.jpg);
color: #666;
font-size: 11px;
font-weight: bold;
line-height: 17px;
padding: 2px 6px;
}
th a:link, th a:visited, th a:hover {
color: #333;
display: block;
font-size: 10px;
text-decoration: none;
width: 100%;
}
th.asc a, th.desc a {
background-position: right;
background-repeat: no-repeat;
}
th.asc a {
background-image: url(../images/skin/sorted_asc.gif);
}
th.desc a {
background-image: url(../images/skin/sorted_desc.gif);
}
.odd {
background: #f7f7f7;
}
.even {
background: #fff;
}
/* LIST */
.list table {
border-collapse: collapse;
}
.list th, .list td {
border-left: 1px solid #ddd;
}
.list th:hover, .list tr:hover {
background: #b2d1ff;
}
/* PAGINATION */
.paginateButtons {
background: #fff url(../images/skin/shadow.jpg) bottom repeat-x;
border: 1px solid #ccc;
border-top: 0;
color: #666;
font-size: 10px;
overflow: hidden;
padding: 10px 3px;
}
.paginateButtons a {
background: #fff;
border: 1px solid #ccc;
border-color: #ccc #aaa #aaa #ccc;
color: #666;
margin: 0 3px;
padding: 2px 6px;
}
.paginateButtons span {
padding: 2px 3px;
}
/* DIALOG */
.dialog table {
padding: 5px 0;
}
.prop {
padding: 5px;
}
.prop .name {
text-align: left;
width: 15%;
white-space: nowrap;
}
.prop .value {
text-align: left;
width: 85%;
}
/* ACTION BUTTONS */
.buttons {
background: #fff url(../images/skin/shadow.jpg) bottom repeat-x;
border: 1px solid #ccc;
color: #666;
font-size: 10px;
margin-top: 5px;
overflow: hidden;
padding: 0;
}
.buttons input {
background: #fff;
border: 0;
color: #333;
cursor: pointer;
font-size: 10px;
font-weight: bold;
margin-left: 3px;
overflow: visible;
padding: 2px 6px;
}
.buttons input.delete {
background: transparent url(../images/skin/database_delete.png) 5px 50% no-repeat;
padding-left: 28px;
}
.buttons input.edit {
background: transparent url(../images/skin/database_edit.png) 5px 50% no-repeat;
padding-left: 28px;
}
.buttons input.save {
background: transparent url(../images/skin/database_save.png) 5px 50% no-repeat;
padding-left: 28px;
}
| 0auf21 | trunk/0auf21/web-app/css/main.css | CSS | bsd | 4,956 |
package de.cecube.v0a21.domain
import grails.test.*
class GroupTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/GroupTests.groovy | Groovy | bsd | 258 |
package de.cecube.v0a21.domain
import grails.test.*
class SeasonTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/SeasonTests.groovy | Groovy | bsd | 259 |
package de.cecube.v0a21.domain
import grails.test.*
class TraineeTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/TraineeTests.groovy | Groovy | bsd | 260 |
package de.cecube.v0a21.domain
import grails.test.*
class ActivityTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/ActivityTests.groovy | Groovy | bsd | 261 |
package de.cecube.v0a21.domain
import grails.test.*
class TrainerTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/TrainerTests.groovy | Groovy | bsd | 260 |
package de.cecube.v0a21.domain
import grails.test.*
class GoalTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/GoalTests.groovy | Groovy | bsd | 257 |
package de.cecube.v0a21.domain
import grails.test.*
class RunnerTests extends GrailsUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
void testSomething() {
}
}
| 0auf21 | trunk/0auf21/test/unit/de/cecube/v0a21/domain/RunnerTests.groovy | Groovy | bsd | 259 |
package com.legendshop.model;
import java.io.Serializable;
public class CallBackEntity
implements Serializable
{
private static final long serialVersionUID = 8483149238149350917L;
private String _$3;
private String _$2;
private String _$1;
public String getCallBackTitle()
{
return this._$3;
}
public void setCallBackTitle(String paramString)
{
this._$3 = paramString;
}
public String getCallBackDesc()
{
return this._$2;
}
public void setCallBackDesc(String paramString)
{
this._$2 = paramString;
}
public String getCallBackHref()
{
return this._$1;
}
public void setCallBackHref(String paramString)
{
this._$1 = paramString;
}
public CallBackEntity(String paramString1, String paramString2, String paramString3)
{
this._$3 = paramString1;
this._$2 = paramString2;
this._$1 = paramString3;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/CallBackEntity.java | Java | oos | 939 |
package com.legendshop.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class UserMessages
implements Serializable
{
private static final long serialVersionUID = 2811715881322185950L;
public static String MESSAGE_KEY = "User_Messages";
private String _$4;
private String _$3;
private String _$2;
private List<CallBackEntity> _$1 = new ArrayList();
public UserMessages()
{
}
public UserMessages(String paramString1, String paramString2, String paramString3)
{
this._$4 = paramString1;
this._$3 = paramString2;
this._$2 = paramString3;
}
public String getTitle()
{
return this._$3;
}
public void setTitle(String paramString)
{
this._$3 = paramString;
}
public String getDesc()
{
return this._$2;
}
public void setDesc(String paramString)
{
this._$2 = paramString;
}
public List<CallBackEntity> getCallBackList()
{
return this._$1;
}
public void addCallBackList(String paramString1, String paramString2, String paramString3)
{
CallBackEntity localCallBackEntity = new CallBackEntity(paramString1, paramString2, paramString3);
this._$1.add(localCallBackEntity);
}
public void addCallBackList(String paramString1, String paramString2)
{
CallBackEntity localCallBackEntity = new CallBackEntity(paramString1, paramString2, null);
this._$1.add(localCallBackEntity);
}
public void addCallBackList(String paramString)
{
CallBackEntity localCallBackEntity = new CallBackEntity(paramString, null, null);
this._$1.add(localCallBackEntity);
}
public boolean hasError()
{
return this._$1.size() > 0;
}
public void setCallBackList(List<CallBackEntity> paramList)
{
this._$1 = paramList;
}
public String getCode()
{
return this._$4;
}
public void setCode(String paramString)
{
this._$4 = paramString;
}
public String toString()
{
return "code = " + this._$4 + ",title = " + this._$3 + ",desc = " + this._$2;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/UserMessages.java | Java | oos | 2,130 |
package com.legendshop.model.visit;
import java.io.Serializable;
import java.util.Date;
public class VisitItem
implements Serializable
{
private static final long serialVersionUID = -6147205011493182266L;
private String _$5;
private String _$4;
private String _$3;
private Date _$2;
private String _$1;
public String getName()
{
return this._$4;
}
public void setName(String paramString)
{
this._$4 = paramString;
}
public String getTitle()
{
return this._$3;
}
public void setTitle(String paramString)
{
this._$3 = paramString;
}
public String getId()
{
return this._$5;
}
public void setId(String paramString)
{
this._$5 = paramString;
}
public Date getDate()
{
return this._$2;
}
public void setDate(Date paramDate)
{
this._$2 = paramDate;
}
public String getPic()
{
return this._$1;
}
public void setPic(String paramString)
{
this._$1 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/visit/VisitItem.java | Java | oos | 1,047 |
package com.legendshop.model.visit;
import com.legendshop.model.entity.ProductDetail;
import com.legendshop.model.entity.ShopDetailView;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
public class VisitHistory
{
private Integer _$3 = Integer.valueOf(6);
private final LinkedList<VisitItem> _$2 = new LinkedList();
private final LinkedList<VisitItem> _$1 = new LinkedList();
private void _$2(VisitItem paramVisitItem)
{
int i = 0;
Iterator localIterator = this._$2.iterator();
while (localIterator.hasNext())
{
VisitItem localVisitItem = (VisitItem)localIterator.next();
if (localVisitItem.getId().equals(paramVisitItem.getId()))
i = 1;
}
if (i == 0)
{
if (this._$2.size() >= this._$3.intValue())
this._$2.removeFirst();
this._$2.addLast(paramVisitItem);
}
}
private void _$1(VisitItem paramVisitItem)
{
int i = 0;
Iterator localIterator = this._$1.iterator();
while (localIterator.hasNext())
{
VisitItem localVisitItem = (VisitItem)localIterator.next();
if (localVisitItem.getId().equals(paramVisitItem.getId()))
i = 1;
}
if (i == 0)
{
if (this._$1.size() >= this._$3.intValue())
this._$1.removeFirst();
this._$1.addLast(paramVisitItem);
}
}
public void visit(ProductDetail paramProductDetail)
{
VisitItem localVisitItem = new VisitItem();
localVisitItem.setName(paramProductDetail.getName());
localVisitItem.setTitle(paramProductDetail.getKeyWord());
localVisitItem.setId(String.valueOf(paramProductDetail.getProdId()));
localVisitItem.setDate(new Date());
localVisitItem.setPic(paramProductDetail.getPic());
_$2(localVisitItem);
}
public void visit(ShopDetailView paramShopDetailView)
{
VisitItem localVisitItem = new VisitItem();
localVisitItem.setName(paramShopDetailView.getStoreName());
localVisitItem.setTitle(paramShopDetailView.getBriefDesc());
localVisitItem.setId(paramShopDetailView.getUserId());
localVisitItem.setDate(new Date());
_$1(localVisitItem);
}
public LinkedList<VisitItem> getVisitProdList()
{
return this._$2;
}
public LinkedList<VisitItem> getVisitShopList()
{
return this._$1;
}
public Integer getMaxLength()
{
return this._$3;
}
public void setMaxLength(Integer paramInteger)
{
this._$3 = paramInteger;
}
public String toString()
{
StringBuffer localStringBuffer = new StringBuffer();
localStringBuffer.append("Visit Product: [ ");
Iterator localIterator = this._$2.iterator();
VisitItem localVisitItem;
while (localIterator.hasNext())
{
localVisitItem = (VisitItem)localIterator.next();
localStringBuffer.append(localVisitItem.getName()).append(", ");
}
localStringBuffer.append("]");
localStringBuffer.append("\nVisit Shop: [ ");
localIterator = this._$1.iterator();
while (localIterator.hasNext())
{
localVisitItem = (VisitItem)localIterator.next();
localStringBuffer.append(localVisitItem.getName()).append(", ");
}
localStringBuffer.append("]");
return localStringBuffer.toString();
}
public LinkedList<VisitItem> getVisitedProd()
{
return this._$2;
}
public LinkedList<VisitItem> getVisitedShop()
{
return this._$1;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/visit/VisitHistory.java | Java | oos | 3,497 |
package com.legendshop.model.dynamic;
import java.io.Serializable;
public class Item
implements Serializable
{
private static final long serialVersionUID = -7793296752968339250L;
private String _$2 = null;
private String _$1 = null;
public Item()
{
}
public Item(String paramString1, String paramString2)
{
this._$2 = paramString1;
this._$1 = paramString2;
}
public Item(Long paramLong, String paramString)
{
this._$2 = String.valueOf(paramLong);
this._$1 = paramString;
}
public String getKey()
{
return this._$2;
}
public void setKey(String paramString)
{
this._$2 = paramString;
}
public String getValue()
{
return this._$1;
}
public void setValue(String paramString)
{
this._$1 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/dynamic/Item.java | Java | oos | 837 |
package com.legendshop.model.dynamic;
import java.io.Serializable;
public class Model
implements Serializable
{
private static final long serialVersionUID = -2267776997265702880L;
private String _$3;
private ModelType _$2;
private Item[] _$1;
public Item[] getItems()
{
return this._$1;
}
public void setItems(Item[] paramArrayOfItem)
{
this._$1 = paramArrayOfItem;
}
public String getId()
{
return this._$3;
}
public void setId(String paramString)
{
this._$3 = paramString;
}
public ModelType getType()
{
return this._$2;
}
public void setType(ModelType paramModelType)
{
this._$2 = paramModelType;
}
public Model clone()
{
Model localModel = new Model();
localModel.setId(getId());
localModel.setItems(getItems());
localModel.setType(getType());
return localModel;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/dynamic/Model.java | Java | oos | 925 |
package com.legendshop.model.dynamic;
public enum ModelType {
Select, Text, Radio, CheckBox;
}
| 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/dynamic/ModelType.java | Java | oos | 105 |
package com.legendshop.model.entity;
import java.io.Serializable;
import java.util.Date;
public class Coupon
implements Serializable
{
private Long _$19;
private String _$18;
private String _$17;
private Long _$16;
private Long _$15;
private Long _$14;
private Long _$13;
private String _$12;
private Long _$11;
private String _$10;
private String _$9;
private String _$8;
private String _$7;
private String _$6;
private Date _$5;
private Date _$4;
private Date _$3;
private Date _$2;
private Integer _$1;
public Long getCouponId()
{
return this._$19;
}
public void setCouponId(Long paramLong)
{
this._$19 = paramLong;
}
public String getUserId()
{
return this._$18;
}
public void setUserId(String paramString)
{
this._$18 = paramString;
}
public String getUserName()
{
return this._$17;
}
public void setUserName(String paramString)
{
this._$17 = paramString;
}
public Long getShopId()
{
return this._$16;
}
public void setShopId(Long paramLong)
{
this._$16 = paramLong;
}
public Long getPartnerId()
{
return this._$15;
}
public void setPartnerId(Long paramLong)
{
this._$15 = paramLong;
}
public Long getProdId()
{
return this._$14;
}
public void setProdId(Long paramLong)
{
this._$14 = paramLong;
}
public Long getSubId()
{
return this._$13;
}
public void setSubId(Long paramLong)
{
this._$13 = paramLong;
}
public String getType()
{
return this._$12;
}
public void setType(String paramString)
{
this._$12 = paramString;
}
public Long getScore()
{
return this._$11;
}
public void setScore(Long paramLong)
{
this._$11 = paramLong;
}
public String getSecret()
{
return this._$10;
}
public void setSecret(String paramString)
{
this._$10 = paramString;
}
public String getStatus()
{
return this._$9;
}
public void setStatus(String paramString)
{
this._$9 = paramString;
}
public String getIp()
{
return this._$8;
}
public void setIp(String paramString)
{
this._$8 = paramString;
}
public String getSmsStatus()
{
return this._$7;
}
public void setSmsStatus(String paramString)
{
this._$7 = paramString;
}
public String getSmsContent()
{
return this._$6;
}
public void setSmsContent(String paramString)
{
this._$6 = paramString;
}
public Date getExpireTime()
{
return this._$5;
}
public void setExpireTime(Date paramDate)
{
this._$5 = paramDate;
}
public Date getConsumeTime()
{
return this._$4;
}
public void setConsumeTime(Date paramDate)
{
this._$4 = paramDate;
}
public Date getCreateTime()
{
return this._$3;
}
public void setCreateTime(Date paramDate)
{
this._$3 = paramDate;
}
public Date getSmsTime()
{
return this._$2;
}
public void setSmsTime(Date paramDate)
{
this._$2 = paramDate;
}
public Integer getBuyId()
{
return this._$1;
}
public void setBuyId(Integer paramInteger)
{
this._$1 = paramInteger;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/Coupon.java | Java | oos | 3,389 |
package com.legendshop.model.entity;
import java.io.Serializable;
public class Logo extends UploadFile
implements Serializable
{
private static final long serialVersionUID = -8146764684614656689L;
private Long _$6;
private String _$5;
private String _$4;
private String _$3;
private String _$2;
private String _$1;
public Logo()
{
}
public Logo(Long paramLong)
{
this._$6 = paramLong;
}
public Logo(Long paramLong, String paramString1, String paramString2, String paramString3, String paramString4)
{
this._$6 = paramLong;
this._$5 = paramString1;
this._$4 = paramString2;
this._$3 = paramString3;
this._$2 = paramString4;
}
public Long getId()
{
return this._$6;
}
public void setId(Long paramLong)
{
this._$6 = paramLong;
}
public String getBanner()
{
return this._$5;
}
public void setBanner(String paramString)
{
this._$5 = paramString;
}
public String getUrl()
{
return this._$4;
}
public void setUrl(String paramString)
{
this._$4 = paramString;
}
public String getUserId()
{
return this._$3;
}
public void setUserId(String paramString)
{
this._$3 = paramString;
}
public String getUserName()
{
return this._$2;
}
public void setUserName(String paramString)
{
this._$2 = paramString;
}
public String getMemo()
{
return this._$1;
}
public void setMemo(String paramString)
{
this._$1 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/Logo.java | Java | oos | 1,593 |
package com.legendshop.model.entity;
import java.io.Serializable;
import java.util.Date;
public class Event
implements Serializable
{
private Long _$7;
private String _$6;
private String _$5;
private String _$4;
private String _$3;
private String _$2;
private Date _$1;
public Long getEventId()
{
return this._$7;
}
public void setEventId(Long paramLong)
{
this._$7 = paramLong;
}
public String getUserId()
{
return this._$6;
}
public void setUserId(String paramString)
{
this._$6 = paramString;
}
public String getUserName()
{
return this._$5;
}
public void setUserName(String paramString)
{
this._$5 = paramString;
}
public String getType()
{
return this._$4;
}
public void setType(String paramString)
{
this._$4 = paramString;
}
public String getOperation()
{
return this._$3;
}
public void setOperation(String paramString)
{
this._$3 = paramString;
}
public String getRelateData()
{
return this._$2;
}
public void setRelateData(String paramString)
{
this._$2 = paramString;
}
public Date getCreateTime()
{
return this._$1;
}
public void setCreateTime(Date paramDate)
{
this._$1 = paramDate;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/Event.java | Java | oos | 1,355 |
package com.legendshop.model.entity;
import java.io.Serializable;
public class Brand extends UploadFile
implements Serializable
{
private static final long serialVersionUID = 3941969699979401870L;
private Long _$6;
private String _$5;
private String _$4;
private String _$3;
private String _$2;
private String _$1;
public Long getBrandId()
{
return this._$6;
}
public void setBrandId(Long paramLong)
{
this._$6 = paramLong;
}
public String getBrandName()
{
return this._$5;
}
public void setBrandName(String paramString)
{
this._$5 = paramString;
}
public String getUserId()
{
return this._$4;
}
public void setUserId(String paramString)
{
this._$4 = paramString;
}
public String getUserName()
{
return this._$3;
}
public void setUserName(String paramString)
{
this._$3 = paramString;
}
public String getMemo()
{
return this._$1;
}
public void setMemo(String paramString)
{
this._$1 = paramString;
}
public String getBrandPic()
{
return this._$2;
}
public void setBrandPic(String paramString)
{
this._$2 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/Brand.java | Java | oos | 1,246 |
package com.legendshop.model.entity;
import java.io.Serializable;
public class PayType
implements Serializable
{
private static final long serialVersionUID = 173116392190218430L;
private Long _$8;
private String _$7;
private Integer _$6;
private String _$5;
private String _$4;
private String _$3;
private String _$2;
private String _$1;
public PayType()
{
}
public PayType(Long paramLong, String paramString, Integer paramInteger)
{
this._$8 = paramLong;
this._$7 = paramString;
this._$6 = paramInteger;
}
public PayType(Long paramLong, String paramString1, Integer paramInteger, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6)
{
this._$8 = paramLong;
this._$7 = paramString1;
this._$6 = paramInteger;
this._$5 = paramString2;
this._$4 = paramString3;
this._$3 = paramString4;
this._$2 = paramString5;
this._$1 = paramString6;
}
public Long getPayId()
{
return this._$8;
}
public void setPayId(Long paramLong)
{
this._$8 = paramLong;
}
public String getUserName()
{
return this._$7;
}
public void setUserName(String paramString)
{
this._$7 = paramString;
}
public Integer getPayTypeId()
{
return this._$6;
}
public void setPayTypeId(Integer paramInteger)
{
this._$6 = paramInteger;
}
public String getPayTypeName()
{
return this._$5;
}
public void setPayTypeName(String paramString)
{
this._$5 = paramString;
}
public String getPartner()
{
return this._$4;
}
public void setPartner(String paramString)
{
this._$4 = paramString;
}
public String getValidateKey()
{
return this._$3;
}
public void setValidateKey(String paramString)
{
this._$3 = paramString;
}
public String getSellerEmail()
{
return this._$2;
}
public void setSellerEmail(String paramString)
{
this._$2 = paramString;
}
public String getMemo()
{
return this._$1;
}
public void setMemo(String paramString)
{
this._$1 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/PayType.java | Java | oos | 2,238 |
package com.legendshop.model.entity;
import java.io.Serializable;
import java.util.Date;
public class NewsCategory
implements Serializable
{
private static final long serialVersionUID = -8019865349891607453L;
private Long _$6;
private String _$5;
private Short _$4;
private Date _$3;
private String _$2;
private String _$1;
public Long getNewsCategoryId()
{
return this._$6;
}
public void setNewsCategoryId(Long paramLong)
{
this._$6 = paramLong;
}
public String getNewsCategoryName()
{
return this._$5;
}
public void setNewsCategoryName(String paramString)
{
this._$5 = paramString;
}
public Short getStatus()
{
return this._$4;
}
public void setStatus(Short paramShort)
{
this._$4 = paramShort;
}
public Date getNewsCategoryDate()
{
return this._$3;
}
public void setNewsCategoryDate(Date paramDate)
{
this._$3 = paramDate;
}
public String getUserId()
{
return this._$2;
}
public void setUserId(String paramString)
{
this._$2 = paramString;
}
public String getUserName()
{
return this._$1;
}
public void setUserName(String paramString)
{
this._$1 = paramString;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/NewsCategory.java | Java | oos | 1,292 |
package com.legendshop.model.entity;
import java.io.Serializable;
import java.util.Date;
public class Product extends UploadFile
implements Serializable
{
private static final long serialVersionUID = -7571396124663475715L;
private Long _$30;
private Long _$29;
private Long _$28;
private Long _$27;
private String _$26;
private String _$25;
private Double _$24;
private Double _$23;
private Double _$22;
private Double _$21;
private String _$20;
private String _$19;
private Integer _$18;
private Integer _$17;
private Date _$16;
private String _$15;
private String _$14;
private Integer _$13;
private Date _$12;
private String _$11;
private String _$10;
private Date _$9;
private Date _$8;
private Integer _$7;
private String _$6;
private String _$5;
private String _$4;
private String _$3;
private Long _$2;
private Integer _$1;
public Product()
{
}
public Product(Long paramLong1, Long paramLong2, Long paramLong3, Long paramLong4, String paramString)
{
this._$30 = paramLong1;
this._$29 = paramLong2;
this._$28 = paramLong3;
this._$27 = paramLong4;
this._$25 = paramString;
}
public Product(Long paramLong1, Long paramLong2, Long paramLong3, Long paramLong4, String paramString1, String paramString2, Double paramDouble1, Double paramDouble2, Double paramDouble3, Integer paramInteger1, Integer paramInteger2)
{
this._$30 = paramLong1;
this._$29 = paramLong2;
this._$28 = paramLong3;
this._$27 = paramLong4;
this._$25 = paramString1;
this._$15 = paramString2;
this._$24 = paramDouble1;
this._$23 = paramDouble2;
this._$22 = paramDouble3;
this._$18 = paramInteger1;
this._$17 = paramInteger2;
}
public Product(Long paramLong1, Long paramLong2, Long paramLong3, Long paramLong4, String paramString1, Double paramDouble1, Double paramDouble2, Double paramDouble3, Double paramDouble4, String paramString2)
{
this._$30 = paramLong1;
this._$29 = paramLong2;
this._$28 = paramLong3;
this._$27 = paramLong4;
this._$25 = paramString1;
this._$24 = paramDouble1;
this._$23 = paramDouble2;
this._$22 = paramDouble3;
this._$21 = paramDouble4;
this._$20 = paramString2;
}
public Product(Integer paramInteger1, Integer paramInteger2, String paramString)
{
this._$18 = paramInteger1;
this._$17 = paramInteger2;
this._$6 = paramString;
}
public Product(Long paramLong1, Long paramLong2, Long paramLong3, String paramString1, String paramString2, Double paramDouble1, Double paramDouble2, Double paramDouble3, Double paramDouble4, String paramString3, String paramString4, Integer paramInteger1, Integer paramInteger2, Date paramDate1, String paramString5, String paramString6, Integer paramInteger3, Date paramDate2, String paramString7, String paramString8, Date paramDate3, Date paramDate4, Integer paramInteger4, String paramString9, String paramString10, String paramString11)
{
this._$29 = paramLong1;
this._$28 = paramLong2;
this._$27 = paramLong3;
this._$26 = paramString1;
this._$25 = paramString2;
this._$24 = paramDouble1;
this._$23 = paramDouble2;
this._$22 = paramDouble3;
this._$21 = paramDouble4;
this._$20 = paramString3;
this._$19 = paramString4;
this._$18 = paramInteger1;
this._$17 = paramInteger2;
this._$16 = paramDate1;
this._$15 = paramString5;
this._$14 = paramString6;
this._$13 = paramInteger3;
this._$12 = paramDate2;
this._$11 = paramString7;
this._$10 = paramString8;
this._$9 = paramDate3;
this._$8 = paramDate4;
this._$7 = paramInteger4;
this._$6 = paramString9;
this._$5 = paramString10;
this._$4 = paramString11;
}
public Long getProdId()
{
return this._$30;
}
public void setProdId(Long paramLong)
{
this._$30 = paramLong;
}
public Long getSortId()
{
return this._$29;
}
public void setSortId(Long paramLong)
{
this._$29 = paramLong;
}
public Long getNsortId()
{
return this._$28;
}
public void setNsortId(Long paramLong)
{
this._$28 = paramLong;
}
public Long getSubNsortId()
{
return this._$27;
}
public void setSubNsortId(Long paramLong)
{
this._$27 = paramLong;
}
public String getModelId()
{
return this._$26;
}
public void setModelId(String paramString)
{
this._$26 = paramString;
}
public String getName()
{
return this._$25;
}
public void setName(String paramString)
{
this._$25 = paramString;
}
public Double getPrice()
{
return this._$24;
}
public void setPrice(Double paramDouble)
{
this._$24 = paramDouble;
}
public Double getCash()
{
return this._$23;
}
public void setCash(Double paramDouble)
{
this._$23 = paramDouble;
}
public Double getProxyPrice()
{
return this._$22;
}
public void setProxyPrice(Double paramDouble)
{
this._$22 = paramDouble;
}
public Double getCarriage()
{
return this._$21;
}
public void setCarriage(Double paramDouble)
{
this._$21 = paramDouble;
}
public String getBrief()
{
return this._$20;
}
public void setBrief(String paramString)
{
this._$20 = paramString;
}
public String getContent()
{
return this._$19;
}
public void setContent(String paramString)
{
this._$19 = paramString;
}
public Integer getViews()
{
return this._$18;
}
public void setViews(Integer paramInteger)
{
this._$18 = paramInteger;
}
public Integer getBuys()
{
return this._$17;
}
public void setBuys(Integer paramInteger)
{
this._$17 = paramInteger;
}
public Date getRecDate()
{
return this._$16;
}
public void setRecDate(Date paramDate)
{
this._$16 = paramDate;
}
public String getPic()
{
return this._$15;
}
public void setPic(String paramString)
{
this._$15 = paramString;
}
public String getCommend()
{
return this._$14;
}
public void setCommend(String paramString)
{
this._$14 = paramString;
}
public Integer getStatus()
{
return this._$13;
}
public void setStatus(Integer paramInteger)
{
this._$13 = paramInteger;
}
public Date getModifyDate()
{
return this._$12;
}
public void setModifyDate(Date paramDate)
{
this._$12 = paramDate;
}
public String getUserId()
{
return this._$11;
}
public void setUserId(String paramString)
{
this._$11 = paramString;
}
public String getUserName()
{
return this._$10;
}
public void setUserName(String paramString)
{
this._$10 = paramString;
}
public Date getStartDate()
{
return this._$9;
}
public void setStartDate(Date paramDate)
{
this._$9 = paramDate;
}
public Date getEndDate()
{
return this._$8;
}
public void setEndDate(Date paramDate)
{
this._$8 = paramDate;
}
public Integer getStocks()
{
return this._$7;
}
public void setStocks(Integer paramInteger)
{
this._$7 = paramInteger;
}
public String getProdType()
{
return this._$6;
}
public void setProdType(String paramString)
{
this._$6 = paramString;
}
public String getKeyWord()
{
return this._$5;
}
public void setKeyWord(String paramString)
{
this._$5 = paramString;
}
public String getAttribute()
{
return this._$4;
}
public void setAttribute(String paramString)
{
this._$4 = paramString;
}
public String getParameter()
{
return this._$3;
}
public void setParameter(String paramString)
{
this._$3 = paramString;
}
public Long getBrandId()
{
return this._$2;
}
public void setBrandId(Long paramLong)
{
this._$2 = paramLong;
}
public Integer getActualStocks()
{
return this._$1;
}
public void setActualStocks(Integer paramInteger)
{
this._$1 = paramInteger;
}
} | 100mall | trunk/100mall/src/main/java/model/com/legendshop/model/entity/Product.java | Java | oos | 8,400 |