private void mainLoop() { long startTime = 0L; long endTime = 0L; long deltaTime = 0L; while (!Display.isCloseRequested()) { startTime = System.currentTimeMillis(); // Run the physics simulation if (useOpenCL) { clPhysics.doPhysics(particleCount, deltaTime); // Render Renderer.render(clPhysics.getCurrentPosBuffer(), particleCount); } else { normalPhysics.doPhysics(particles, boxWidth, boxHeight, deltaTime); // Render Renderer.render(particles); } // Update the display Display.update(); endTime = System.currentTimeMillis(); deltaTime = endTime - startTime; System.out.println(deltaTime); } }
/** main renderer */ public void run() { // MEASURE ELAPSED TIME AND FRAMERATE elapsed += getCurrentTime() - currentTime; currentTime = getCurrentTime(); if (isDamage) { frameRate = .9 * frameRate + .1 / elapsed; elapsed = 0; // LET THE APPLICATION PROGRAMMER MOVE THINGS INTO PLACE identity(); // APPLIC. MATRIX STARTS UNTRANSFORMED // isDamage = true; renderer.rotateView(theta, phi); theta = phi = 0; ianimate(currentTime - startTime); // APPLICATION ANIMATES THINGS // SHADE AND SCAN CONVERT GEOMETRY INTO FRAME BUFFER renderer.refresh(); renderer.render(); // KEEP REFINING LEVEL OF DETAIL UNTIL PERFECT (WHEN LOD=1) if (renderer.lod > 1) { isDamage = true; renderer.lod--; } } }
@Override public void render(GraphNode resource, GraphNode context, String mode, OutputStream os) throws IOException { Renderer renderer = manager.createRenderer(resource, mode, mediaTypeList); if (renderer == null) { throw new RuntimeException( "no renderer could be created for " + resource + " (in " + resource.getNodeContext() + "), " + mode + "," + mediaTypeList); } renderer.render( resource, context, mode, uriInfo, requestHeaders, responseHeaders, sharedRenderingValue, os); }
/** {@inheritDoc} */ public S render(T entity) { // This reflection charade is necessary because we can't convince the // compiler that the output of renderer1 is compatible with the input // of renderer2 without exposing a redundant "intermediate" type parameter // in the class definition. I don't what to do that, I'd rather have // the ugliness encapsulated here than complicate code that uses this class. Method renderMethod = ReflectionUtils.findKnownMethod(Renderer.class, "render", Object.class); return ReflectionUtils.<S>invokeUnchecked(renderMethod, renderer2, renderer1.render(entity)); }
public static TabledDescriptorRenderer renderUpperBoundViolatedInferenceError( InferenceErrorData inferenceErrorData, TabledDescriptorRenderer result) { TypeParameterDescriptor typeParameterDescriptor = null; for (TypeParameterDescriptor typeParameter : inferenceErrorData.descriptor.getTypeParameters()) { if (!ConstraintsUtil.checkUpperBoundIsSatisfied( inferenceErrorData.constraintSystem, typeParameter, true)) { typeParameterDescriptor = typeParameter; break; } } assert typeParameterDescriptor != null; result .text( newText() .normal("Type parameter bound for ") .strong(typeParameterDescriptor.getName()) .normal(" in ")) .table(newTable().descriptor(inferenceErrorData.descriptor)); JetType inferredValueForTypeParameter = ConstraintsUtil.getValue( inferenceErrorData.constraintSystem.getTypeConstraints(typeParameterDescriptor)); assert inferredValueForTypeParameter != null; JetType upperBound = typeParameterDescriptor.getUpperBoundsAsType(); JetType upperBoundWithSubstitutedInferredTypes = inferenceErrorData .constraintSystem .getResultingSubstitutor() .substitute(upperBound, Variance.INVARIANT); assert upperBoundWithSubstitutedInferredTypes != null; Renderer<JetType> typeRenderer = result.getTypeRenderer(); result.text( newText() .normal(" is not satisfied: inferred type ") .error(typeRenderer.render(inferredValueForTypeParameter)) .normal(" is not a subtype of ") .strong(typeRenderer.render(upperBoundWithSubstitutedInferredTypes))); return result; }
@Override public void render(GL gl) { if (!init) return; if (ssName != null) { takeScreenshot(ssName); ssName = null; } renderer.render(drawable, config.graphics); }
protected void render(boolean refresh) { if (refresh) { clear(); } int rowCount = getRowsToBeRendered(); for (int i = 0; i < rowCount; i++) { T value = dataProvider.get(); if (value == null) { throw new DataProviderExcpetion("Index error = " + i); } renderer.render(value); if (dataProvider.hasNext()) { dataProvider.next(); } else { break; } } updatePager(); }
public void testRenderer() { Renderer r = GWT.create(Renderer.class); SafeHtmlBuilder b = new SafeHtmlBuilder(); r.render(b, values); Element e = UiBinderUtil.fromHtml(b.toSafeHtml().asString()); Document.get().getBody().appendChild(e); try { assertEquals(values.anUnsafeUri(), r.getJsAnchorFromSafeUri(e).getHref()); AnchorElement anchor = expectedEscapedAnchor(); assertEquals(anchor.getHref(), r.getJsAnchorFromString(e).getHref()); assertEquals("http://www.google.com/images/logo_sm.gif", r.getInlineHttpAnchor(e).getHref()); assertEquals("javascript:void(0)", r.getInlineJavascriptAnchor(e).getHref()); assertEquals( values.aSelector() + values.aGifPath(), r.getHttpAnchorFromConstructedString(e).getHref()); } finally { e.removeFromParent(); } }
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String Request_Url = request .getRequestURI() .substring(request.getContextPath().length(), request.getRequestURI().length() - 2); String Request_Method = request.getMethod().toUpperCase(); RequestHandler handler = eipkMvcLoader.getRequestHandler(Request_Url, Request_Method); if (handler != null) { Method method = handler.getMethod(); Object eipkControllerBean = eipkMvcLoader.getBean(handler.getEipkControllerClass()); try { method.setAccessible(true); Object result = method.invoke(eipkControllerBean, new Model(request)); log.log( Level.INFO, "Eipk Controller " + handler.getEipkControllerClass().getName() + "." + handler.getMethod().getName() + "() invoked,url:" + Request_Url); if (handler.isAjax()) { System.out.println("我在调度器…是AJAX"); AjaxData ajaxData; if (result == null) { ajaxData = new AjaxData(new HashMap<String, Object>()); System.out.println("我在调度器……result为空"); } else { ajaxData = (AjaxData) result; } Object model = ajaxData.getModel(); response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); if (model != null) { String json = SysUtil.ObjToJson(model); byte[] buff = json.getBytes(); response.setContentLength(buff.length); response.getOutputStream().write(buff); System.out.println("我在调度器……model不为空"); } } else { System.out.println("我在调度器……不是ajax"); String view = (String) result; if (view.indexOf(".x") > 0) { response.sendRedirect(request.getContextPath() + view); System.out.println("我有.x我跳转了"); } else { response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); Renderer renderer = new Renderer(response, request, view); renderer.render(); System.out.println("我没有.x我转向其他区域"); } } } catch (Exception e) { System.out.println("我怎么到了这里"); log.log( Level.INFO, "Eipk Controller " + handler.getEipkControllerClass().getName() + "." + handler.getMethod().getName() + "() invoke failed,url:" + Request_Url); System.out.println("出错了小伙子"); e.printStackTrace(); } } else { log.log(Level.INFO, "未找到匹配的控制器方法[" + Request_Url + "]"); response.sendRedirect(request.getContextPath() + "/err.x?id=1"); } }
/** * Basic Framework implicitely also processes, i'm not sure if we should require any framework to * do that (perhaps we could say, that the render method must process, if that is necessary, and * not yet done). */ @Override public void render( Renderer renderer, Parameters blockParameters, Parameters frameworkParameters, Writer w, WindowState windowState) throws FrameworkException { ServletRequest request = frameworkParameters.get(Parameter.REQUEST); if (request == null) { throw new IllegalArgumentException("No request object given"); } State state = State.getState(request); if (state .isRendering()) { // mm:component used during rending of a component, that's fine, but use a // new State. state = new State(request); log.debug("Alreadying rendering, taking a new state for sub-block-rendering: " + state); } log.debug("Rendering " + renderer.getBlock() + " " + renderer); Object prevHints = request.getAttribute(RenderHints.KEY); try { request.setAttribute(COMPONENT_CLASS_KEY, getComponentClass()); request.setAttribute(COMPONENT_CURRENTUSER_KEY, getUserNode(frameworkParameters)); Renderer actualRenderer = state.startBlock(frameworkParameters, renderer); if (!actualRenderer.equals(renderer)) { Parameters newBlockParameters = actualRenderer.getBlock().createParameters(); newBlockParameters.setAllIfDefined(blockParameters); blockParameters = newBlockParameters; } state.setAction(request.getParameter(ACTION.getName())); if (state.needsProcess()) { log.service("Performing action on " + actualRenderer.getBlock()); Processor processor = actualRenderer.getBlock().getProcessor(); state.process(processor); log.service("Processing " + actualRenderer.getBlock() + " " + processor); setBlockParametersForProcess(state, blockParameters); processor.process(blockParameters); state.endProcess(); } state.render(actualRenderer); setBlockParametersForRender(state, blockParameters); RenderHints hints = new RenderHints( actualRenderer, windowState, state.getId(), getComponentClass(), RenderHints.Mode.NORMAL); request.setAttribute(RenderHints.KEY, hints); actualRenderer.render(blockParameters, w, hints); request.setAttribute("org.mmbase.framework.hints", hints); } catch (FrameworkException fe) { log.debug(fe); URI uri = renderer.getUri(); Renderer error = new ErrorRenderer( renderer.getType(), renderer.getBlock(), (uri != null) ? uri.toString() : null, 500, fe); RenderHints hints = new RenderHints( error, windowState, state.getId(), getComponentClass(), RenderHints.Mode.NORMAL); error.render(blockParameters, w, hints); } finally { request.setAttribute(RenderHints.KEY, prevHints); state.endBlock(); } }
@Override public void acceptRenderer(Renderer renderer) { renderer.render(this); }