Search in sources :

Example 1 with LoggerLevel

use of gaiasky.util.Logger.LoggerLevel in project gaiasky by langurmonkey.

the class NotificationsInterface method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    synchronized (lock) {
        switch(event) {
            case POST_NOTIFICATION:
                LoggerLevel level = (LoggerLevel) data[0];
                Object[] dat = (Object[]) data[1];
                String message = "";
                boolean perm = false;
                for (int i = 0; i < dat.length; i++) {
                    if (i == dat.length - 1 && dat[i] instanceof Boolean) {
                        perm = (Boolean) dat[i];
                    } else {
                        message += dat[i].toString();
                        if (i < dat.length - 1 && !(i == dat.length - 2 && dat[dat.length - 1] instanceof Boolean)) {
                            message += TAG_SEPARATOR;
                        }
                    }
                }
                addMessage(message, perm, level);
                break;
            case FOCUS_CHANGED:
                if (data[0] != null) {
                    IFocus sgn = null;
                    if (data[0] instanceof String) {
                        sgn = GaiaSky.instance.sceneGraph.findFocus((String) data[0]);
                    } else {
                        sgn = (IFocus) data[0];
                    }
                    addMessage(I18n.txt("notif.camerafocus", sgn.getName()));
                }
                break;
            case TIME_STATE_CMD:
                Boolean bool = (Boolean) data[0];
                if (bool == null) {
                    addMessage(I18n.txt("notif.toggle", I18n.txt("gui.time")));
                } else {
                    addMessage(I18n.txt("notif.simulation." + (bool ? "resume" : "pause")));
                }
                break;
            case TOGGLE_VISIBILITY_CMD:
                if (data.length == 2)
                    addMessage(I18n.txt("notif.visibility." + (((Boolean) data[1]) ? "on" : "off"), I18n.txt((String) data[0])));
                else
                    addMessage(I18n.txt("notif.visibility.toggle", I18n.txt((String) data[0])));
                break;
            case FOCUS_LOCK_CMD:
            case ORIENTATION_LOCK_CMD:
            case TOGGLE_AMBIENT_LIGHT:
            case OCTREE_PARTICLE_FADE_CMD:
                addMessage(data[0] + (((Boolean) data[1]) ? " on" : " off"));
                break;
            case CAMERA_MODE_CMD:
                CameraMode cm = (CameraMode) data[0];
                if (cm != CameraMode.FOCUS_MODE)
                    addMessage(I18n.txt("notif.cameramode.change", data[0]));
                break;
            case TIME_WARP_CHANGED_INFO:
                addMessage(I18n.txt("notif.timepace.change", data[0]));
                break;
            case FOV_CHANGE_NOTIFICATION:
                // addMessage("Field of view changed to " + (float) data[0]);
                break;
            case JAVA_EXCEPTION:
                Throwable t = (Throwable) data[0];
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                t.printStackTrace(pw);
                String stackTrace = sw.toString();
                if (data.length == 1) {
                    if (I18n.bundle != null)
                        addMessage(I18n.txt("notif.error", stackTrace));
                    else
                        addMessage("Error: " + stackTrace);
                } else {
                    if (I18n.bundle != null)
                        addMessage(I18n.txt("notif.error", data[1] + TAG_SEPARATOR + stackTrace));
                    else
                        addMessage("Error: " + data[1] + TAG_SEPARATOR + stackTrace);
                }
                break;
            case ORBIT_DATA_LOADED:
                addMessage(I18n.txt("notif.orbitdata.loaded", data[1], ((PointCloudData) data[0]).getNumPoints()), false, LoggerLevel.DEBUG);
                break;
            case SCREENSHOT_INFO:
                addMessage(I18n.txt("notif.screenshot", data[0]));
                break;
            case STEREOSCOPIC_CMD:
                addMessage(I18n.txt("notif.toggle", I18n.txt("notif.stereoscopic")));
                break;
            case DISPLAY_GUI_CMD:
                boolean displayGui = (Boolean) data[0];
                addMessage(I18n.txt("notif." + (!displayGui ? "activated" : "deactivated"), data[1]));
                break;
            case STEREO_PROFILE_CMD:
                addMessage(I18n.txt("notif.stereoscopic.profile", StereoProfile.values()[(Integer) data[0]].toString()));
                break;
            case FRAME_OUTPUT_CMD:
                boolean activated = (Boolean) data[0];
                if (activated) {
                    addMessage(I18n.txt("notif.activated", I18n.txt("element.frameoutput")));
                } else {
                    addMessage(I18n.txt("notif.deactivated", I18n.txt("element.frameoutput")));
                }
                break;
            case SCREEN_NOTIFICATION_CMD:
                String title = (String) data[0];
                String[] msgs = (String[]) data[1];
                float time = (Float) data[2];
                // Log to output
                addMessage(title);
                for (String msg : msgs) addMessage(msg);
                break;
            case MODE_POPUP_CMD:
                ModePopupInfo mpi = (ModePopupInfo) data[0];
                if (mpi != null) {
                    addMessage(mpi.title);
                    addMessage(mpi.header);
                    for (Pair<String[], String> p : mpi.mappings) {
                        String[] keys = p.getFirst();
                        String action = p.getSecond();
                        StringBuilder msg = new StringBuilder();
                        msg.append("<");
                        for (int i = 0; i < keys.length; i++) {
                            msg.append(keys[i].toUpperCase());
                            if (i < keys.length - 1) {
                                msg.append("+");
                            }
                        }
                        msg.append("> " + action);
                        addMessage(msg.toString());
                    }
                }
                break;
            default:
                break;
        }
    }
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData) StringBuilder(com.badlogic.gdx.utils.StringBuilder) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) LoggerLevel(gaiasky.util.Logger.LoggerLevel) IFocus(gaiasky.scenegraph.IFocus) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 2 with LoggerLevel

use of gaiasky.util.Logger.LoggerLevel in project gaiasky by langurmonkey.

the class ConsoleLogger method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case POST_NOTIFICATION:
            LoggerLevel level = (LoggerLevel) data[0];
            Object[] dat = (Object[]) data[1];
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < dat.length; i++) {
                if (i != dat.length - 1 || !(dat[i] instanceof Boolean)) {
                    message.append(dat[i].toString());
                    if (i < dat.length - 1 && !(i == dat.length - 2 && dat[data.length - 1] instanceof Boolean)) {
                        message.append(TAG_SEPARATOR);
                    }
                }
            }
            addMessage(message.toString(), level);
            break;
        case FOCUS_CHANGED:
            if (data[0] != null) {
                IFocus sgn = null;
                if (data[0] instanceof String) {
                    sgn = GaiaSky.instance.sceneGraph.findFocus((String) data[0]);
                } else {
                    sgn = (IFocus) data[0];
                }
                addMessage(I18n.txt("notif.camerafocus", sgn.getName()));
            }
            break;
        case TIME_STATE_CMD:
            Boolean bool = (Boolean) data[0];
            if (bool == null) {
                addMessage(I18n.txt("notif.toggle", I18n.txt("gui.time")));
            } else {
                addMessage(I18n.txt("notif.simulation." + (bool ? "resume" : "pause")));
            }
            break;
        case TOGGLE_VISIBILITY_CMD:
            if (data.length == 2)
                addMessage(I18n.txt("notif.visibility." + (((Boolean) data[1]) ? "on" : "off"), I18n.txt((String) data[0])));
            else
                addMessage(I18n.txt("notif.visibility.toggle", I18n.txt((String) data[0])));
            break;
        case FOCUS_LOCK_CMD:
        case ORIENTATION_LOCK_CMD:
        case TOGGLE_AMBIENT_LIGHT:
        case OCTREE_PARTICLE_FADE_CMD:
            addMessage(data[0] + (((Boolean) data[1]) ? " on" : " off"));
            break;
        case CAMERA_MODE_CMD:
            CameraMode cm = (CameraMode) data[0];
            if (cm != CameraMode.FOCUS_MODE)
                addMessage(I18n.txt("notif.cameramode.change", data[0]));
            break;
        case TIME_WARP_CHANGED_INFO:
            addMessage(I18n.txt("notif.timepace.change", data[0]));
            break;
        case FOV_CHANGE_NOTIFICATION:
            // addMessage("Field of view changed to " + (float) data[0]);
            break;
        case JAVA_EXCEPTION:
            Throwable t = (Throwable) data[0];
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            t.printStackTrace(pw);
            String stackTrace = sw.toString();
            if (data.length == 1) {
                if (I18n.bundle != null)
                    addMessage(I18n.txt("notif.error", stackTrace));
                else
                    addMessage("Error: " + stackTrace);
            } else {
                if (I18n.bundle != null)
                    addMessage(I18n.txt("notif.error", data[1] + TAG_SEPARATOR + stackTrace));
                else
                    addMessage("Error: " + data[1] + TAG_SEPARATOR + stackTrace);
            }
            break;
        case ORBIT_DATA_LOADED:
            addMessage(I18n.txt("notif.orbitdata.loaded", data[1], ((PointCloudData) data[0]).getNumPoints()), LoggerLevel.DEBUG);
            break;
        case SCREENSHOT_INFO:
            addMessage(I18n.txt("notif.screenshot", data[0]));
            break;
        case STEREOSCOPIC_CMD:
            addMessage(I18n.txt("notif.toggle", I18n.txt("notif.stereoscopic")));
            break;
        case DISPLAY_GUI_CMD:
            boolean displayGui = (Boolean) data[0];
            addMessage(I18n.txt("notif." + (!displayGui ? "activated" : "deactivated"), data[1]));
            break;
        case STEREO_PROFILE_CMD:
            addMessage(I18n.txt("notif.stereoscopic.profile", Settings.StereoProfile.values()[(Integer) data[0]].toString()));
            break;
        case FRAME_OUTPUT_CMD:
            boolean activated = (Boolean) data[0];
            if (activated) {
                addMessage(I18n.txt("notif.activated", I18n.txt("element.frameoutput")));
            } else {
                addMessage(I18n.txt("notif.deactivated", I18n.txt("element.frameoutput")));
            }
            break;
        default:
            break;
    }
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) LoggerLevel(gaiasky.util.Logger.LoggerLevel) IFocus(gaiasky.scenegraph.IFocus) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Aggregations

PointCloudData (gaiasky.data.util.PointCloudData)2 IFocus (gaiasky.scenegraph.IFocus)2 CameraMode (gaiasky.scenegraph.camera.CameraManager.CameraMode)2 LoggerLevel (gaiasky.util.Logger.LoggerLevel)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 StringBuilder (com.badlogic.gdx.utils.StringBuilder)1